am-impact / amnav

Navigation plugin for Craft
168 stars 20 forks source link

Use Global Variables? #3

Closed lancejanocha closed 9 years ago

lancejanocha commented 9 years ago

Just wondering if it would be possible to use a global variable in the nav structure?

For example - working on a site that has links to a few 3rd party services, I am storing these url's as Craft Globals for use throughout the site (some content specific CTA's etc). I would like to be able to create utility navigation for the header/footer that includes these global urls without 'hard coding' the url a second time and relying on the global var to control the items URL.

Right now the Global/Twig variable is saved as a string and never parsed. (< a href="{{ global.myUrl }}">Link to service</ a> is output - no spaces in actual output ;) )

hubertprein commented 9 years ago

Right now it doesn't support the use of Global Variables, but I might include it in a later version. I don't have an ETA on this for now though.

silentworks commented 9 years ago

You can currently do this in Craft by default, just parse your output like below:

<a href="{{ include(template_from_string(global.myUrl)) }}">Link to service</a>

this would parse the global and output the value assigned.