Forums / Templates, Stylesheets, Page Layout / separating pages with body ID and if/then statements

separating pages with body ID and if/then statements

Locked

Started by doodlebee on 13 Jan 2007, 2:42 PM · Views: 2,689

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
13 Jan 2007, 2:42 PM
#1
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

separating pages with body ID and if/then statements

Okay, I'll start off by saying this: in my "tpl_main_page.php" file, I've edited the <body> line so it looks like this:

if($current_page_base == 'index' and $_GET['main_page'] == 'index' and $current_category_id=='') { ?>
<body id="index">
<?php } else if ($current_page_base == 'page') { ?>
<body id="page">
<?php } else if ($current_page_base == 'login' or $current_page_base == 'account' or $current_page_base == 'account_edit' or $current_page_base == 'address_book' or $current_page_base == 'account_password' or $current_page_base == 'account_newsletters' or $current_page_base == 'account_notifications' or $current_page_base == 'time_out' or $current_page_base == 'logoff') { ?>
<body id="account">
<?php } else { ?>
<body id="category<?php echo $current_category_id; ?>">
<?php } ?>

Now, the point of this is so that when certain pages are viewed, it gives the body a different ID tag (or styling purposes - I can style each page individually if I need to with this tag). So, for example, my category 15 page shows up with <body id="category15">, my ezpages show up with <body id="page"> and so on. It's very helpful for the site I'm working on.

However, now I'm running into an itsy-bitsy issue. On site pages that aren't in any category, and aren't pages, they all have "category0" for the body ID. (So, all of my "checkout" pages are <body id="category0">, for example. However, there are a couple of pages that aren't in categories, are not EZ-Pages and are not checkout pages (for example, my 404 page).

Let's go with the 404 page. So I want that page to be styled a little bit differently, however, I don't know how to edit the above code to reflect that. Would anyone know what "if" statement I need to add in up there to get my 404 page to have a different body ID? I don't quite know what these pages qualify as so I can put the proper stuff in there to make it recognize that page.

Thanks for any help :)

13 Jan 2007, 2:46 PM
#2
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Ah crap. And two seconds later I figure it out. Why does it work that way? I bang my head for hours, then I post the question and suddenly it comes to me? Criminy.

Anyway, if anyone else needs to know, for the 404 page it's:

<?php } else if ($current_page_base == 'page_not_found') { ?>
<body id="not_found">
<?php } else { ?>

so basically, it seems that the filename is the page base. (I could be wrong on that - but that's what is working!)

13 Jan 2007, 6:03 PM
#3
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: separating pages with body ID and if/then statements

version 1.3.7 does this for you automatically and without all the if/then statements.

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

14 Jan 2007, 12:44 AM
#4
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

True, but it pretty much gives a new name for every page (I'm running 1.3.7) - which causes major CSS bloat. I just wanted my "pages" to look the same, my "categories" to look the same, etc. Whereas before, I was getting a new body ID for every page that showed up in the cart. That's why I replaced it with the if/then statements.

14 Jan 2007, 2:05 AM
#5
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,846
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

explain css "bloat"......I'm working on a store with at least 20 different page and category stylesheets, when a page loads it only loads the main stylesheet and the one for that page or category not the rest....So I don't see where your gaining by having unique body ids

Now, the point of this is so that when certain pages are viewed, it gives the body a different ID tag (or styling purposes - I can style each page individually if I need to with this tag). So, for example, my category 15 page shows up with <body id="category15">, my ezpages show up with <body id="page"> and so on. It's very helpful for the site I'm working on.

with out any coding changes I can style any of my category pages with C_1.css, c_3_29, so on and so forth and I'm only using those extra stylesheets to tweak a couple of things so those stylesheets are only about 10 lines long.....no bloat here. You may have to explain better where your gaining this way cause I don't see it.....but I don't like to bend things to much I might break em and then Linda gets mad at me.

Mike
AEIIA - Zen Cart Certified & PCI Compliant Hosting
The Zen Cart Forum...Better than a monitor covered with post-it notes!

15 Jan 2007, 3:21 AM
#6
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

I would guess it depends upon what type of layout you're going for. In my case, the site I'm working on is seriously customized. All of my "category" pages look the same (except for one - and that category page is radically different form any other one), all of my EZ Pages look the same, so on and so forth.

The original code, as I recall (it's been a few months since I've changed it) would put in a unique ID for every page - in fact, let me verify since I'm now starting a very new website with the same level of customization, and I haven't touched the code yet...

So the body ID is "indexBody" for the index page. An EZ Page is "page2Body", but the third EZ page is "page3Body". For Product pages and such, it was giving me the same type of thing - the body ID was different for every single page I was on.

Perhaps we are using two different methods for the same solution - I don't know But for me, having those extra body ID's when they weren't needed was unnecessary and creating a lot of CSS code bloat. The way I have it now, all of my EZ pages are body id="page", all of my account pages are body id="account", and so on.

True, I suppose I could have just loaded stylesheets as the pages load - that's a good idea that I had never noticed before. But I do think that we are both discussing two methods to solve the same problem.

(and I don't know who "Linda" is...:) )

15 Jan 2007, 7:17 AM
#7
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,846
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Linda=Ajeh......and she gets cranky when I break things.....:lamo:

Mike
AEIIA - Zen Cart Certified & PCI Compliant Hosting
The Zen Cart Forum...Better than a monitor covered with post-it notes!

17 Jan 2007, 2:00 AM
#8
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Wow! Ajeh's a girl? Who knew? (You know, besides her and you ;) ) Cool.

Well, I'm trying out this neat little "css by page" thing - and it's actually pretty freaking cool. Thanks for the tip on that!

17 Jan 2007, 2:50 AM
#9
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,846
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Wow! Ajeh's a girl? Who knew? (You know, besides her and you ;) ) Cool.
Do I detect a note of sarcasm......hmmmm
Have you not notice Ajeh, one of the development team, has her name in her signature........

Mike
AEIIA - Zen Cart Certified & PCI Compliant Hosting
The Zen Cart Forum...Better than a monitor covered with post-it notes!

17 Jan 2007, 1:44 PM
#10
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Do I detect a note of sarcasm

No - no sarcasm, I swear. I had no idea.

And yes, I just realized yesterday (after reading your post) that yep - there's her signature, right there! I've seen it before, but it never really registered, know what I mean? I don't know, I always thought she was a teenage boy - senior in high school/early college years (hopefully she doesn't kill me for saying so!) I think it was her avatar that gave me that impression.

Apologies about from me, Linda! (But yes, it's awesome when I see females who are so tech-savvy - I don't see it a whole lot!)

And again, thanks for the tip on the stylesheets - it's too late for me to implement it on a site I'm currently finishing up, but I'm working on a new one, and it's proving to be extremely helpful.

20 Jan 2007, 5:45 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: separating pages with body ID and if/then statements

I wish I was still a kid ... gads I'd be so smart then, with years and years ahead of me ... :smartass:

But no ... I am a tad ... umm ... older now ... so I am only a genius at this point but, I strive to be humble ...

Not sure why no one can tell that is a female elf ... but alas ... I have had that mentioned once or twice ... :lamo:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

25 Jan 2007, 3:26 PM
#12
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

Not sure why no one can tell that is a female elf

because it's kinda flat-chested and it's anime - which means that all characters look feminine (typical of anime-style art) Usually, breasts or a skirt would give away the *** of the character, but this one has niether, so usually you're safe to assume it's male :)

By the way - Ohio? Hello former neighbor. I'm originally from WV (worked in Ohio at my last job - lived right on the border) How's the weather over there? ;)

28 Jan 2007, 4:25 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: separating pages with body ID and if/then statements

Snow ... cold ... snow ... cold ... and more snow ...

Other than that ... it's great ... :eek:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Jan 2007, 1:55 PM
#14
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: separating pages with body ID and if/then statements

I'm jealous. I love snow. I had to move up here to CT last year, and I was expecting feet of the white stuff, and I still haven't seen any. It's ridiculous.

Anyway, this thread has gone WAY OT - I thank you all for the help. Now I need ot look up more info on this already impleneted stylesheet thing (I can't believe I didn't notice that before) and try to figure out how it works...that's gonna be so handy.