If current page is a certain page type then return a string

Permalink 1 user found helpful
Hi there,

I'm fairly new to concrete5 and new to PHP, so I am looking for some assistance, please.

In my theme, I have set a page to a 'blog_entry' type.

To test what I'm trying to achieve, in my page template, I added the syntax:

<?php echo $c->getCollectionTypeHandle(); ?>


Which correctly outputs 'blog_entry' as a text string.

When I try to echo a different string based on the output, the wrong values are being returned.

The full code I'm using at the moment is:

<?php if ($c->getCollectionTypeHandle == 'blog_entry') {
    echo 'This page is a blog entry';
} else {
    echo 'This page is not a blog entry';
}
?>
<?php echo $c->getCollectionTypeHandle(); ?>


This returns: This page is not a blog entry blog_entry.

If any one could please advice why the correct string isn't being returned then that would be very helpful.

Thanks

 
washingbasket replied on at Permalink Reply
My bad...I realised I was missing the parenthesis in the if statement:

<?php if ($c->getCollectionTypeHandle() == 'blog_entry') {
    echo 'This page is a blog entry';
} else {
    echo 'This page is not a blog entry';
}
?>
<?php echo $c->getCollectionTypeHandle(); ?>