orchardcms - How to add Orchard shape to start of body? -
orchardcms - How to add Orchard shape to start of body? -
i'm getting started orchard , writing module google tag manager means need add together javascript snippet @ start of body tag every page in our site.
in filterprovider onresultexecuting i've got
var context = _workcontextaccessor.getcontext(); var tags = context.layout.body; var snippet = shape.snippet(); snippet.containerid = containerid; tags.add(snippet); where shape defaultshapefactory. know shape.add has sec argument position, i've tried ":before", ".5", "1" no success. gets rendered @ end of body, using thememachine theme no modifications.
if modify theme , add together new zone either document or layout view @ start of body , add together shape appears there solution now, means we'll have ensure theme build has zone in right place.
how add together shape in code body , command position?
this code works:
context.layout.body.items.insert(0, snippet) your code not work because of
body shape created coreshapes class , specific shape added default (null) position. sorting shapes within body take place flatpositioncomparer class , null position converted "before" position. so specific shape has highest priority , first place in list. , nil move it. orchardcms
Comments
Post a Comment