I have some template code that I want to re-use within a sidebar across a lot of pages in my site. Some of this template code is conditional based on what directory you’re in on the site, etc. So, right now, I’m using a slot to include this content with this defined template.
However, that means that each page that uses this has to define a content_item for that slot, which is a lot of overhead. I don’t really need an associated content_item … I just want to call in the template globally, and then make some decisions in that template based on location.
Is there a way to just drop a snippet of HTML template code into a slot, without having to define a content_item for that slot on every page that uses it?
I don’t believe there is way to include template code in a slot without an associated content item. The basic paradigm behinds slots is that one is allowed to insert certain content types rendered using certain snippet templates.
What you may want to do is use define a custom macro, rather than using a slot. We do this for certain modules which are common on many pages (for example, a widget allowing visitors to share a page via social media channels). In the file rx_assembly.vm, you can write your own velocity macros which you can then call within any template.
Thanks for the note. As you may have guessed, I’m new to Percussion and trying to figure out the proper way to go about things.
I have some a few examples of custom Velocity macros, so I will check into that option.
Checkout this thread. If you want an item added at a section level and be shown on every item within that section you can use this. You add the item to a slot on the Navon and it will be as if it has been added to all items the slot is used on below that. Be careful though as incremental publishing as a change to the slot on navon can cause a lot of items below to require republishing, and incremental may not pick this up.