Strange template issue - existing page displays fine, new pages have no editable regions

Permalink
Hi There,

I'm trying to troubleshoot a weird template issue. To launch a site, I hid the news section and left the news template unfinished with one news item.

I've now completed the template and am ready to make the site live but whenever I create a new news item, no editable regions show up and neither does the sidebar.

When I view the rendered source, I'm seeing an error on a call to a custom attribute which is the news image.

The error is:
<b>Fatal error</b>:  Call to a member function getVersion() on a non-object in <b>/home/site-name/themes/theme-name/news_entry.php</b> on line <b>34</b>


Line 34 is the call to grab the image which looks like this:
<p class="left"><img src="<?php echo($c->getAttribute('main_image')->getVersion()->getRelativePath());?>" width="300" height="184"></p>


The only thing I added to the template was the date like this:
<p class="date"><?php echo $c->getCollectionDatePublic('D F j, Y') ?></p>


BTW, if I remove the image php, it works.

Not sure what I've done wrong as the existing news story renders fine and they both use the same page type/template.

Is it because there's no image for this news story maybe?

Any help would be much appreciated.

Cheers

Ben

 
cmscss replied on at Permalink Reply
OK, I fixed the issue above with a little conditional which test to see if the image is there:
<!-- entry image -->
   <?php if ($c->getAttribute('main_image')) { ?>
      <p class="left"><img src="<?php echo($c->getAttribute('main_image')->getVersion()->getRelativePath());?>" width="300" height="184"></p>
   <?php } ?>


Is that the right way to handle this?


The weird thing is that on the news home page now, the previous news item's thumbnail image appears in the page list (this news item doesn't have an image).

If I insert an image into the story it replaces it but when you delete the image, the second story gets the first story's image in the list - is there a default setting maybe?

Here is the call that grabs the custom image attribute in the custom pagelist template:
<!-- entry thumbnail -->
   <p><a <?php echo $target ?> href="<?php echo $link ?>"><?php echo "<img src=\"{$thumbnailObj->src}\" alt=\"\" width=\"150\" />"; ?></a><p>



Man, you step away from a new CMS for a few weeks and BAM - you feel like a beginner!

Any know what I might be doing wrong?