Hi all. The first MODx site I constructed followed the "standard" model with a single template consisting of nested divs, sidebar nav, and a content div which displayed the actual page content.
My second "test" is enough different that I would love suggestions as to how to proceed. In essense, the sidebar *and* the content area are different for each page -- the sidebar (with its own div) displays different images (that are differently formatted) for each page. I don’t think that having a unique template for each page makes any sense. so what is the recommended technique for using a single common template for multiple pages, but having two (or more) areas within the template be different for each page?
Thanks in advance for any insights / suggestions / examples!
-
☆ A M B ☆
- 24,524 Posts
That is precisely what Template Variables (TVs) are for:
http://www.sottwell.com/how-template-variables-work.html
Thanks for the quick reply! Would it make sense to use two Template Variables -- one to specify the image for the page and one to specify the CSS class for formatting, or is there a better way?
-
☆ A M B ☆
- 24,524 Posts
If you use an image type input, AND an image output widget, the output widget lets you specify the img tag attributes, such as classnames. When creating your TV, in the Widget drop-down, select Image. A whole bunch of input fields will be displayed. Fill out what you want and leave the rest blank. The TV will automatically generate the <img...> tags.
However, if you want to have different classnames for the documents, then yes, another TV would be appropriate. In that case, don’t select an output widget. Your HTML would look something like this:
<img src="[*imageTV*]" class="[*imageClassTV*]" alt="whatever" />
Or
<img src="[*imageTV*]" class="[*imageClassTV*]" alt="[*imageAltTV*]" />
If you want to set the Alt value when you edit the other stuff.
-
☆ A M B ☆
- 24,524 Posts
For something as simple as that, I just use a <style ...> block in my template head with the TV tags. Keep in mind that a document used as a CSS file would need to use a snippet to determine which document’s value to use (and would that be the referrer? Do CSS request pass a referrer?); when MODx parses the CSS document it would be looking at the value for the document it’s parsing (which being the CSS document doesn’t have it at all).