Developer forum

Forum » Development » Create Custom Global Tags

Create Custom Global Tags


Reply
Hi there,

Is there a way to create custom global tags that are also accessible in menu XSLT files? I am trying to render some custom stuff that I need to use in an XSLT file and in other locations, but I don't know how. Tried it as a PageTemplateExtender but didn't see the results show up in the XSLT file....

Thanks in advance,

Imar

Replies

 
Reply
I don't think it is possible.
 
When an XML menu is generated, tags are added from Pageview.GetGlobalTags()
GetGlobalTags does not include any custom global tags.
 
Pageview.Output() has this notification... 
NotificationManager.Notify("DWN_STANDART_PAGE_AFTER_RENDER", new object[] { globalTemplate });
 
If DW would just create a similar notification inside GetGlobalTemplateTags, then our global tags would be available as XML in XML menu templates and any other XSLT template.
 
Nicolai Høeg Pedersen
Reply
You can use Notifications.Standard.Page.AfterOutput to make your own global tags - except for in navigation.

Just made the XmlDocument property public so it can be manipulated through navigation providers.

Also made a Notifications.Standard.Page.OnGlobalTags notification that can be used to add your own global tags - also for xmlnavigation.

Out with 7.2
 
Rene Poulsen
Reply
How does this actually work, Nicolai? I'm trying to create my own global tags (in DW8). I'm Subscribing to the Standard.Page.AfterOutput, casting my args as Standard.Page.AfterOutputArgs. On these args there is a template object on which you can call the SetTag method, but it doesn't seem to work.

I've tried to use the OnGlobalTags notification, but there is no OnGlobalTagsArgs. If this is what i need to do, what should i cast the Args as?

Thanks in advance,

René

 
Rene Poulsen
Reply
Sorry, of course it's working. I looked for the tag by writing out DwTemplateTags but the notification happens (as the name indicates) after the output is generated. So the tag won't show up in the tag list when using DwTemplateTags, but I can use it anyway :-)
 
Nicolai Høeg Pedersen
Reply
Hi Rene

Can be tricky...
But use the OnGlobalTags notification with Notifications.Standard.Page.PageviewNotificationArgs. It has a template property where you can set global tags. And then they should also appear in DwTemplateTags.

BR Nicolai

 
Nicolai Høeg Pedersen
Reply
A sample:



 [Extensibility.Subscribe(Dynamicweb.Notifications.Standard.Page.OnGlobalTags)]
    public class PageviewObserver : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null)            
                return;

            Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs pna = (Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs)args;
            
            //To do - insert your code here
            
        }
    }

 
Rene Poulsen
Reply
Perfect! Thank you Nicolai!

 

You must be logged in to post in the forum