Please explain magic of hasContent('extended')

Feed 3 posts, 2 voices

Aug 18, 2008 19:30
Avatar
4 posts

Does hasContent() only work with parts named extended? If I add 2 parts to a page one named "coolpart" and the other named "extended" and then add $this->hasContent('coolpart'); $this->hasContent('extended'); they both display the extended part. Am I totally missing something here? Thanks everybody.

 
Aug 18, 2008 19:37
Avatar
142 posts

Hey jonathanpaul,

If you edit the layout that the page is assigned to and drop in something along the lines of:

    <?php if ($this->hasContent('coolpart')): ?>
        <div id="coolpart">
            <?php echo $this->content('coolpart'); ?>
        </div>
    <?php endif; ?>

    <?php if ($this->hasContent('extended')): ?>
        <div id="extended">
            <?php echo $this->content('extended'); ?>
        </div>
    <?php endif; ?>

You should be able to separate out the content. This code will check to see if the Page has that content and will print the code on runtime if it has :)

Hope this helps

Andy

 
Aug 18, 2008 19:53
Avatar
4 posts

Thanks Andy. You have confirmed my understanding. My problem (and confusion) was that I had a error in the code I was trying to execute and the reason only hasContent('extended') would work it that it is included near the end of the default or "normal" layout. Thanks for the help.

 
Aug 18, 2008 21:45
Avatar
142 posts

No probs, glad I could be of assistance :)