Show a block only on homepage
PermalinkLike a "if else" function:
if () {
Content Block
} else {
No Content Block
}
Thanks in advance!
I could just include another footer, but i was looking for a better way.
So i will try the reply of Mnkras.
Will let you all know if this works for the footer include works.
Does anyone have another suggestion?
and something like
$page = $pageType->getCollectionTypeHandle() if( $page == home ) //code else //code
didn't work?
if ($c->getCollectionID() == 1) { CODE GOES HERE }
I've another maybe more comfortable and userfriendly method of doing this.
I'm using page attributes.
Mostly boolean types, because they're easier for cients.
Little example: add a boolean page attribute
Add that attribut to your specific page and check it. It's so easy, just uncheck it to disable it.
<?php if($c->getCollectionAttributeValue('my_attribute') == 1) { echo '<script type="text/javascript" src="'. $this->getThemePath().'/js/myscript.js"></script>'; }
^^ I know I could use the htmlHelper.. but well it's not as powerfull as I wished it was. Meaning it doesnt support defer attributes in script and charset and many other attributes of the <link tag too. This could be implemented really easily, I would do that, but I'm not that familiar with custom function parameter amounts. I don't know howto create a function without ending with a function call like this: $html->example('defer',1,'xy',3,null,'hello',null,null,null);
The nulls^ are annoying..
This way I avoid having too many page_types.
How does that cID work?
If the about page is on the second place in the sitemap then cID == 2 ?
so do if $pagetype = home
//code
else
//code
or just make a pagetype specifically for the homepage