I’m using modX to run a local newspaper’s website, and everything works really well. There are just a few things that I’d like to hear a few opinions on.
Like I said it’s a newspaper website and I have tried to emulate the look of the paper as much as possible. The layout for the front page stories is the area of concern for me. The paper can have many different layout possibilities. Such as, you could have a story with 3 mugs, or a graph, or it could contain an image with a cutline, or it could be a single pull quote from the story itself. I’m using ditto to output the front page stories of that week’s issue from a specific folder to the index page of the website. The ditto call works great and does what I want it to. The issue I’m having concerns with is the chunk I made that ditto uses to render the stories.
I’m using template variables to hold a specific image, or pull quote, or mug image that is associated with a particular story. Like I said, I’m using a chunk for ditto to use to output front page stories. I’m also using phx to use some logic within the chunk. The chunk contains the following code:
<h1><a href="[~[+id+]~]" title="[+longtitle+]">[+pagetitle+]</a></h1>
[+phx:if=`[+subhead+]`:isnot=``:then=`<h2>[+subhead+]</h2>`:else=` `+]
[+phx:if=`[+Graph-image+]`:isnot=``:then=`<p class="graph"><a href="[~[+id+]~]" title="[+longtitle+]">[+Graph-image+]</a></p>`:else=` `+][+phx:if=`[+Graph-datasource+]`:isnot=``:then=`<p class="data-source">[+Graph-datasource+]</p>`:else=` `+]
[+phx:if=`[+Photo+]`:isnot=``:then=`<p class="mug-photo"><a href="[~[+id+]~]" title="[+longtitle+]">[+Photo+]</a></p>`:else=` `+][+phx:if=`[+Photo+]`:isnot=``:then=`<p class="cutline">[+cutline+]</p>`:else=` `+]
[+phx:if=`[+Mug3+]`:isnot=``:then=`<div class="mug">`:else=` `+][+phx:if=`[+Mug3+]`:isnot=``:then=`<p>[+Mug3+]</p>`:else=` `+][+phx:if=`[+Mug-caption3+]`:isnot=``:then=`<p class="mug-caption">[+Mug-caption3+]</p>`:else=` `+][+phx:if=`[+Mug3+]`:isnot=``:then=`</div>`:else=` `+]
[+phx:if=`[+Mug2+]`:isnot=``:then=`<div class="mug">`:else=` `+][+phx:if=`[+Mug2+]`:isnot=``:then=`<p>[+Mug2+]</p>`:else=` `+][+phx:if=`[+Mug-caption2+]`:isnot=``:then=`<p class="mug-caption">[+Mug-caption2+]</p>`:else=` `+][+phx:if=`[+Mug2+]`:isnot=``:then=`</div>`:else=` `+]
[+phx:if=`[+Mug+]`:isnot=``:then=`<div class="mug">`:else=` `+][+phx:if=`[+Mug+]`:isnot=``:then=`<p>[+Mug+]</p>`:else=` `+][+phx:if=`[+Mug-caption+]`:isnot=``:then=`<p class="mug-caption">[+Mug-caption+]</p>`:else=` `+][+phx:if=`[+Mug+]`:isnot=``:then=`</div>`:else=` `+]
[+phx:if=`[+pullquote+]`:isnot=``:then=`<div class="pullquote">`:else=` `+][+phx:if=`[+pullquote+]`:isnot=``:then=`<p class="pullquote-text">[+pullquote+]</p>`:else=` `+][+phx:if=`[+pullquote+]`:isnot=``:then=`<p class="pullquote-whosaid">[+pullquote-whosaid+]</p>`:else=` `+][+phx:if=`[+pullquote+]`:isnot=``:then=`<p class="pullquote-whoarethey">[+pullquote-whoarethey+]</p>`:else=` `+][+phx:if=`[+pullquote+]`:isnot=``:then=`</div>`:else=` `+]
<p>[+summary+]</p>
<p class="more-story"><a href="[~[+id+]~]" title="Read the full article...">Read full story...</a></p>
i put some line breaks in there so you could see a little better as to what I’m trying to accomplish. The logic is something like,
If a story contains an image or cutline, output it, if a story contains one or more mugs output the mugs and associated mug captions, otherwise, don’t output anything.. And so on. The same logic applies to graphs or pull quotes, what have you.
The problem is, sometimes a story will contain an image with a cutline and a pullquote and a mug. I could not use all four template variables, because the chunk above is meant to display just an introduction to the story with a single image and cutline or two or three mugs with mug captions. But if I have to use an image, cutline and pull quote in the story, the chunk above will output both the image, cutline and the pullquote in the front page summary.
I guess what I need to know is, how can I make it so that the ditto chunk above will only output one of the desired template variables in the summary?
Do I just need to redesign the whole logic of how this works? It seems so overly complicated, or am I just making that way? I’d love to hear how a more accomplished modX’er would have accomplished the above.
Sorry about the long post, it’s just one of those problems that’s so hard to summarize. ;-)
Thanks!