Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Removing Elements on Main Page Only

Removing Elements on Main Page Only

Locked

Views: 997

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
10 Dec 2008, 11:19 AM
#1
craig_robbo avatar

craig_robbo

Zen Follower

Join Date:
Oct 2008
Posts:
109
Plugin Contributions:
0

Removing Elements on Main Page Only

Hi

I've seen the answer to this before but have tried searching and cannot find it.

I was chasing the code to comment out sections of the stylesheet for the main page only.

It was similar to;

If=main_page then ignore

Any help would be really appreciated

10 Dec 2008, 11:26 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removing Elements on Main Page Only

To disable code on the home page:```php
if (!$this_is_home_page) {
//your code
}

To run code on the home page only:```php
if ($this_is_home_page) {
  //your code
}

Note that this will not work inside the stylesheet.
You can address elements occurring on the home page with #indexHome prefixed to the selector.

#indexHome .leftBoxContents {

10 Dec 2008, 11:34 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removing Elements on Main Page Only

Ran out of time to edit...

You can address elements occurring on the home page with #indexHomeBody prefixed to the selector.

#indexHomeBody .leftBoxContents {

10 Dec 2008, 12:02 PM
#4
craig_robbo avatar

craig_robbo

Zen Follower

Join Date:
Oct 2008
Posts:
109
Plugin Contributions:
0

Re: Removing Elements on Main Page Only

Sorry i'm a bit new to CSS.

If i cant use it in the style sheet where do i put it?

and would "ignore" work as below
if (!$this_is_home_page) {
//ignore
}

and (sorry i know i'm pushing it with this many questions) will using #indexHomeBody in front of elements stop them occuring on the main page?

10 Dec 2008, 12:13 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removing Elements on Main Page Only

The #indexHomeBody prefix will address a common element only when it occurs on the home page. You can use this to add special styling instructions for the home page, like
display: none;
if you want the element to disappear there.

if (!$this_is_home_page) {
//ignore
}

//ignore
is just a comment and will do nothing.
Wrapping the if code as shown around your other code is what will cause that to be run only if not on the home page (i.e., ignored on the home page).

This would be used in PHP files. You should learn something about how PHP works before trying to make edits like this.
Look at https://www.w3schools.com for basic PHP and CSS tutorials.

10 Dec 2008, 12:37 PM
#6
craig_robbo avatar

craig_robbo

Zen Follower

Join Date:
Oct 2008
Posts:
109
Plugin Contributions:
0

Re: Removing Elements on Main Page Only

Will do. Thanks alot for your time though. Did you know if there was an easy way to stop the footer appearing on the home page for the time being?

Thanks again.

10 Dec 2008, 10:44 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removing Elements on Main Page Only

Look at /includes/templates/your_template/common/tpl_main_page.php (copy it from /template_default/ if needed.)

There are notes in that file that describe how to disable elements, like the footer for the home page.

11 Dec 2008, 3:55 AM
#8
craig_robbo avatar

craig_robbo

Zen Follower

Join Date:
Oct 2008
Posts:
109
Plugin Contributions:
0

Re: Removing Elements on Main Page Only

Ahh...exactly what I was after. Thanks - worked a treat!