-
- 7,075 Posts
Pretty nifty tutorial Raymond, I’ll take the time to translate in french when I get the chance... and use it myself when the need arises !
Thanks
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
-
- 194 Posts
I’m working on a similar feature without using TVs, just a custom snippet; what I want for my side columns is content that changes automatically following the site section the visitor is browsing, for example:
HOMEPAGE
Left Column -> latest News (Ditto snippet pulling from the News Subfolder)
Right Column -> Tag cloud (another snippet configured on document keywords)
ACTIVITIES
Left Column -> sub-nav list of arguments (DropMenu snippet from the Activities submenu)
Right Column -> Related arguments (ListRelated snippet)
PROJECTS
Left Column -> some other specific Chunk
Right Column -> more stuff saved in a chunk
...
The side columns are not directly editable as with TVs, but still this gives a very dynamic site, all managed with a single template. There ’s really no limit to each column content you can have multiple calls to different snippets; and/or calls to Chunks and TVs for each section.
The Snippet php code is pretty simple: starting from the current doc ID I reconstruct its position in the site document tree; then I just have an if-block that returns different chunks or Snippet calls by matching the docID and parentID with the sections IDs.
Inside the HTML template I have one call to the snippet from each side column; I do pass the column value (left, right) as an argument in the snippet call, but one can also create a specific Snippet for each column to avoid passing this argument (de gustibus).
I’m using the same technique with another Snippet that takes care of the header: the site is going to be bi-lingual thus in the root level I have 2 folders, one for english and one for italian docs; this snippet checks if the current doc is in one folder or the other and loads the GUI (main navigation block) in the correct language.
I have a template with a right column <div> which only contains a TV, [*rightcolumn*]. Same for the left column. I have default values in the actual TV for both. Now, for every document I make using that template, I have an edit field for those TVs just below the doucment content edit field. If I do nothing, that page will have the default content. If I edit the content for that document, that page will show my edited content.
So while the TVs will have default content, for every document you can edit the TV for that document.
You can browse through the manager of my site if you want to see what I mean.