I’m not sure the title of my post properly explains what Im trying to accomplish so please excuse me if I go into some depth here.
I’ve been playing around with template variables and have got to grips with the ’basics’, I have created a TV which drops a box in the left col of my site with some header text, an image, and a link to a pdf. All nice and easy so far.
Heres comes my problem!
I have four page templates on the site and the TVs have been properly assigned to these. There are roughly 15 pages in total on the site, I currently have to set the TVs independently on each page, is it possible to set them on one page and then have the propogate throughout the site?
In other words, is it possible to only update on TV on one page, and then have every other page reflect the changes made to TV? Or will my client have to go through manually updating each page (which is more flexible in the long run, but a bit of a ballache!)
I’m a designer rather than a programmer, and I have to admit, I’m finding the implmentation of TV’s a bit challenging!
-
☆ A M B ☆
- 24,524 Posts
a TV can have a default value when you create it, which will be used by all pages until you edit the TV on a page. You can also use a default of @INHERIT, then you edit the TV on a parent document’s page and all of its children will inherit its value.
..and you can access TVs from other documents using the GetField snippet.
Cheers for the info, I think the GetField snippet sounds like the way to go, although its useful being able to set default values, it won’t really help my client update the site in the future.
I’ll let you know how I get on.
-
MODX Staff
- 12,272 Posts
That’s relatively straightforward to do:
[*] Create your site structure and make sure the "subpages" are stored inside the home page in the tree menu (making it a container)
[*] Create your TVs and make sure they’re attached to all your templates
[*] Give your TVs a default value of @INHERIT
Using the above formula, anything that you put into the TV on the home page will automatically inherit to all descendant documents/containers.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
I had a bash at that earlier on Ryan, but managed to nause up my wayfinder calls in the process (Noob that i am!). I was just sitting on the toilet having a think (as you do!) and I thought of another way, I could setup chunks containing all the relevant links and info and then use the dynamic chunks snippets tutorial in the modx wiki. That way all the client would have to do is click a checkbox to select the chunk to display.
The downside of my approach is that obviously at some point in the future the client would want to come back to me to get the chunks amended. (I’m a pretty hands off kinda guy once the sites been handed over!)
Cheers for all the suggestions though, the support and discourse is very much appreciated. I shall have another pop at implementing ryans suggestion and keep me fingers crossed!
-
☆ A M B ☆
- 24,524 Posts
Your Wayfinder call could have its startId be the ID of the home page. The home page itself would be represented by the &displayStart parameter, with a &startItemTpl to format it. Then use CSS to blend them together so the end user won’t know (unless he does a View Source) that they aren’t all in the same structure.
Note that, if &displayStart parameter is set to TRUE, then Wayfinder will place the output of &outerTpl (which contains the entire menu structure!) into the [+wf.wrapper+] placeholder of the &startItemTpl, so be sure to include this placeholder in your custom template!
Hurrah! Sussed it!
I followed Ryans instructions and created a container and moved all my docs inside it, hid the container from the menu, then set the startID of wayfinder to that of the container, Bobs your uncle! it all works perfectly.
The homepage btw, shares the same template as the parent container, that way when people 1st enter the site they actually see the hidden page, all other links lead back and forth between the files inside the container.
Well chuffed thats sorted, and again thanks for all the help. Next up. Implementing dynamic chunks on the homepage and propogating them throughout the site.