Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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:

    Code:
    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 :)

  2. #2
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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:

    Code:
    <?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!)

  3. #3
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default 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.

  4. #4
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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.

  5. #5
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,742
    Plugin Contributions
    0

    Default 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
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  6. #6
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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...:) )

  7. #7
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,742
    Plugin Contributions
    0

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

    Linda=Ajeh......and she gets cranky when I break things.....
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  8. #8
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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!

  9. #9
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,742
    Plugin Contributions
    0

    Default 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
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  10. #10
    Join Date
    Jan 2006
    Posts
    229
    Plugin Contributions
    0

    Default 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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Create an SSL accessible page outside the store and then use ez-pages to link to it
    By tonyreaper in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 27 Nov 2012, 12:37 AM
  2. v138a Linking to an EZ Page or Separating EZ Pages into Drop Downs
    By AE12 in forum General Questions
    Replies: 5
    Last Post: 7 Nov 2012, 05:30 PM
  3. adding conditional statements for pages
    By whiteboxer in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 9 Feb 2010, 11:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR