Show a block only on homepage
Permalink
Can someone tell me how i can show some content ONLY on the homepage?
Like a "if else" function:
if () {
Content Block
} else {
No Content Block
}
Thanks in advance!
Like a "if else" function:
if () {
Content Block
} else {
No Content Block
}
Thanks in advance!
Couldn't you just add the block only to the homepage?
No because its in the footer element..
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.
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'nt work in the footer element.
Does anyone have another suggestion?
Does anyone have another suggestion?
make a pagetype for the home page
and something like
didn't work?
and something like
$page = $pageType->getCollectionTypeHandle() if( $page == home ) //code else //code
didn't work?
This is what I always use, assuming the cID of your homepage hasn't changed:
if ($c->getCollectionID() == 1) { CODE GOES HERE }
thanks for sharing this :)
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.
^^ 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.
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.
Thanks hursey013, that worked for me :)
How does that cID work?
If the about page is on the second place in the sitemap then cID == 2 ?
How does that cID work?
If the about page is on the second place in the sitemap then cID == 2 ?
nope its in the order the pages were created
Were can i see what the cID # is?
If you go to a page from the Site Map (from the Dashboard), you will see it in the URL in the form ofhttp://www.example.com/?cID=X, where X is the cID.
so do if $pagetype = home
//code
else
//code
or just make a pagetype specifically for the homepage