Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30
  1. #21
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by rbarbour View Post
    Not my intentions, I also agree that their is no downside, just giving alternatives and suggestions.
    I appreciate the insight as always.. For the record I tried a BUNCH of other code based solutions and had only partial success.. I may eventually go back to one of them at some later point and try to work out the kinks.. but that day ain't today!!
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  2. #22
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by rbarbour View Post
    Why not just wrap the entire container in the if statement, no need for CSS
    Before I comment further, I will state that there is no 'right' or 'wrong' way of achieving the desired results, but personally I tend towards using CSS for this kind of thing rather than code. I find it helps separate function from content.

    Having said that, in a case like this (without having a stylesheet for each page) there is always going to be *some* code required anyway.

    Although my original suggestion to DivaVocals was along the lines of the solution taken, in reality I probably would have opted for a slightly different method.

    Code:
    <?php 
    $style = "display:none";  
        if ($this_is_home_page) {
           $style = "display:block !important" ;
         } 
    
    
    echo "<style>#ez-feature-top-container-wrap {$style;}</style>";
    ?>
    The benefit of using this method over the solution taken is that the $style variable can be initialised at the top of the page, with the actual echo/output located deeper in the code where it is actually needed/used.

    Nah... I just changed my mind again :)

    Something like

    Code:
     $useClass = "ez-feature-top-container-wrap hidden" ;
    
     if ($this_is_home_page) {
    $useClass = "ez-feature-top-container-wrap" ;
    } 
    
    
    echo "<div class=$useClass>" ;
    
    
    ... stuff goes here ..
    
    
    echo "</div>" ;
    Then in my stylesheet.css

    Code:
    .ez-feature-top-container-wrap {
    display: block ; 
    }
    
    .ez-feature-top-container-wrap hidden {
    display: none ; 
    }
    The reason why I believe this is a better option (bearing in mind I've no real idea what is actually to be displayed) is that this allows additional control for mobile devices. For example, if the output happens to be a large banner that simply doesn't 'work' correctly on a mobile device, then another addition to the stylesheet along the lines of.................

    Code:
    @media (max-width: 320px) {  
     
      ez-feature-top-container-wrap {
     display: none ;
        }
    }
    .... can be used... The net result being the banner (or whatever) will only be displayed on the home page but only if the screen width is larger than 320px.

    Pretty neat eh?

    Cheers
    RodG

  3. #23
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Hide a <div> in JUST the home page..

    Agree, no "right" way, also offerring solutions, so this is what I was referring.

    Knowing that it would be a "mostly" off condition, the stylesheet.css would have the do not display css associated with the div tag, and only one specialized css sheet would be needed to unhide the div.

    The index_home.css sheet would contain the css to unhide the div. In the sequence of loading the stylesheet.css would load first with the hide property in all cases. When the home page is the page loaded, then the index_home.css file content would be loaded and that css will override the stylesheet css. Tada not a million sheets, just two. The only code hack was to add the tag(s) to begin with...like Rod was getting at, then also have more control over when/how the content is shown

    Used: http://www.zen-cart.com/wiki/index.p...Per-Page-Rules
    As a reference.
    Last edited by mc12345678; 29 Sep 2014 at 06:51 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #24
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide a <div> in JUST the home page..

    thanks everyone.. I'll take a look at those alternate solutions..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  5. #25
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: Hide a <div> in JUST the home page..

    Very neat, thank you.

  6. #26
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by RodG View Post
    Before I comment further, I will state that there is no 'right' or 'wrong' way of achieving the desired results, but personally I tend towards using CSS for this kind of thing rather than code. I find it helps separate function from content.

    Having said that, in a case like this (without having a stylesheet for each page) there is always going to be *some* code required anyway.

    Although my original suggestion to DivaVocals was along the lines of the solution taken, in reality I probably would have opted for a slightly different method.

    Code:
    <?php 
    $style = "display:none";  
        if ($this_is_home_page) {
           $style = "display:block !important" ;
         } 
    
    
    echo "<style>#ez-feature-top-container-wrap {$style;}</style>";
    ?>
    The benefit of using this method over the solution taken is that the $style variable can be initialised at the top of the page, with the actual echo/output located deeper in the code where it is actually needed/used.
    For personal reasons I prefer not to add CSS declarations in CODE.

    Quote Originally Posted by RodG View Post
    Nah... I just changed my mind again :)

    Something like

    Code:
     $useClass = "ez-feature-top-container-wrap hidden" ;
    
     if ($this_is_home_page) {
    $useClass = "ez-feature-top-container-wrap" ;
    } 
    
    
    echo "<div class=$useClass>" ;
    
    
    ... stuff goes here ..
    
    
    echo "</div>" ;
    Then in my stylesheet.css

    Code:
    .ez-feature-top-container-wrap {
    display: block ; 
    }
    
    .ez-feature-top-container-wrap hidden {
    display: none ; 
    }
    The reason why I believe this is a better option (bearing in mind I've no real idea what is actually to be displayed) is that this allows additional control for mobile devices. For example, if the output happens to be a large banner that simply doesn't 'work' correctly on a mobile device, then another addition to the stylesheet along the lines of.................

    Code:
    @media (max-width: 320px) {  
     
      ez-feature-top-container-wrap {
     display: none ;
        }
    }
    .... can be used... The net result being the banner (or whatever) will only be displayed on the home page but only if the screen width is larger than 320px.
    I use a very similar CODE and CSS in my responsive templates to hide/show the side-boxes.

    Quote Originally Posted by RodG View Post

    Pretty neat eh?

    Cheers
    RodG
    Yep, pretty neat!

  7. #27
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by rbarbour View Post
    For personal reasons I prefer not to add CSS declarations in CODE.
    Same here (which is why I changed my mind about using that method). Doing so pretty much defeats the purpose of .css.

    It comes in handy for 'quick n dirty' testing/development though (sometimes). For me, it much depends whether I'm using an IDE or a text editor on a live site. ;-)

    I also have no qualms in using it when trying to help others using their own code snippets.... before offering/suggesting more advanced/better methods.

    Like I said at the outset, I don't consider any particular way of doing things as being 'right' or 'wrong' (I figure, as long as it works, its 'right', and if it doesn't work, it's 'wrong'). LOL

    Cheers
    RodG

  8. #28
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by RodG View Post

    Like I said at the outset, I don't consider any particular way of doing things as being 'right' or 'wrong' (I figure, as long as it works, its 'right', and if it doesn't work, it's 'wrong'). LOL

    Cheers
    RodG
    LMAO - couldn't have put it better!

  9. #29
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by RodG View Post

    Something like

    Code:
     $useClass = "ez-feature-top-container-wrap hidden" ;
    
     if ($this_is_home_page) {
    $useClass = "ez-feature-top-container-wrap" ;
    } 
    
    
    echo "<div class=$useClass>" ;
    
    
    ... stuff goes here ..
    
    
    echo "</div>" ;
    Then in my stylesheet.css

    Code:
    .ez-feature-top-container-wrap {
    display: block ; 
    }
    
    .ez-feature-top-container-wrap hidden {
    display: none ; 
    }
    Gonna give this a looksee, but I'm not entirely sure that this will work for my particular situation.. Not sure that the index_home.css suggestion is THAT much different that the solution I have working now..

    Long term though, I have been brainstorming approaching this from a different angle. Gonna explore some other options within my WordPress theme framework to improve the Zen Cart/WordPress theme integration I am after.. The container I am trying to suppress comes from a special widget that is part of the theme framework and it is not possible to call this widget on it's own.. So instead of using it, I am looking at creating a custom widget and shortcode for this custom widget. Then I can wrap the shortcode PHP inside the "$this_is_home_page" condition..

    But that is long term.... Meanwhile gonna stick with my short term solution..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  10. #30
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Hide a <div> in JUST the home page..

    Quote Originally Posted by RodG View Post
    Like I said at the outset, I don't consider any particular way of doing things as being 'right' or 'wrong' (I figure, as long as it works, its 'right', and if it doesn't work, it's 'wrong'). LOL
    Yep.. for now the solution in place is achieving my IMMEDIATE objective.. But I appreciate the suggestions from everyone.. Ya'll have FORCED me to look at a longer term solution NOW!!! Which I would have done anyway because IMHO my current solution is a bandaid.. I'm not a fan of leaving bandaids in place long term..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Checkout Confirmation Page - Radio Button to Hide Div
    By limelites in forum General Questions
    Replies: 0
    Last Post: 1 May 2012, 11:28 PM
  2. I can see the banner just in the home page...
    By Chris1 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 3 Feb 2011, 11:02 AM
  3. where is the div tag for... Home :: All Products
    By hangman21 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 Jul 2010, 09:11 AM
  4. Changing Page Titles. Not just on the Home Page
    By Globie in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 30 Aug 2008, 11:35 PM
  5. How to get just text on the home page?
    By heapy in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 27 Sep 2007, 06:39 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