Hi there:
I’ve followed and implemented Shaun McCormick’s incredible blog tutorial on multiple sites and it works great. Now trying to take it to the next level by adding a thumbnail image on the right-hand side of each blog summary on the blog articles listing page. I want it so that the site editor can upload an image by way of a TV.
Cutting to the chase, the solution I’ve implemented works great in any other page besides the blog summary page.
Here are the steps I’ve followed:
1. I created the blog (well, a news page in my case) by following the instructions on this page:
http://rtfm.modx.com/display/revolution20/Creating+a+Blog+in+MODx+Revolution which works great.
2. To implement the image, I created a TV with the name of newsSummaryThumbnail, giving it an input type of image. Input Option Values are .jpg, .png. Output Type is default. Template Access is set to BlogPostTemplate (see blog tutorial above...I used the same names as on that tutorial).
3. Installed the If snippet. Thanks to ’pleth’ for his help on this page:
http://modxcms.com/forums/index.php/topic,62869.0.html for how to implement it.
4. Did some CSS work to create a DIV to contain and place the thumbnail, floated to the right.
5. In the blogPost chunk (again, see blog tutorial above) I placed the following code at the top:
[[!If? &subject=`[[*newsSummaryThumbnail]]` &operator=`empty` &then=`` &else=`<div id="news_summary_thumbnail"><img src="[[*newsSummaryThumbnail]]" /></div>`]]
The ’news_summary_thumbnail’ is the CSS ID that places the code on the page.
The whole code on the blogPost page looks like:
[[!If? &subject=`[[*newsSummaryThumbnail]]` &operator=`empty` &then=`` &else=`<div id="news_summary_thumbnail"><img src="[[*newsSummaryThumbnail]]" /></div>`]]
<div class="post">
<h2 class="title"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h2>
<p class="post-info">Posted by [[+createdby:userinfo=`fullname`]]</p>
<div class="entry">
<p>[[+introtext]]</p>
</div>
<p class="postmeta">
<span class="links">
<span class="date">[[+publishedon:strtotime:date=`%b %d, %Y`]] | <a href="[[~[[+id]]]]" class="readmore">Read more</a></a>
</span>
</span>
</p>
</div>
6. Tested the thing by uploading an image by way of my created TV.
...nothing showed.
Some observations:
1. When I put something between the empty backticks, such as the word ’test’, like:
[[!If? &subject=`[[*newsSummaryThumbnail]]` &operator=`empty` &then=`test` &else=`<div id="news_summary_thumbnail"><img src="[[*newsSummaryThumbnail]]" /></div>`]]
...and have nothing else in the TV, then the word ’test’ shows up okay, telling me that the system works in general (as in, the thing is empty, so show the word ’test’). It’s just that the ’then show this, else’ part thinks there is nothing to show even if I do have something in the TV.
2. When I test the code by placing it in other pages, it works great, including the placement of the DIV.
3. When I change the TV so that the Input Type is something else, such as Textarea (mini)...to rule out an image-specific problem...it still doesn’t work.
Can anyone spot what might be wrong? Are there any other suggestions to accomplish what I’m trying to accomplish?
Thank you in advance.
Revo 2.0.6
PHP Version 5.2.10