Forums

[resolved] Do not display a specific Widget for a specific page (10 posts)

  1. MtnBikerSoCal
    Member
    Posted 3 years ago #

    I am using Plugin: NextGEN Gallery and have a slideshow in the sidebar placed there with a widget. Is it possible not to have the slideshow showing on a specific page (which is a page of with the photo gallery and I don't want the clutter of more photo stuff)?

    I see but not sure how to work with this in the case of something installed with using Widgets.

  2. asechrest
    Member
    Posted 3 years ago #

  3. MtnBikerSoCal
    Member
    Posted 3 years ago #

    Thank you. Looks like a winner.

    I see that I messed up my post a bit. I messed up the link for Conditional Tags

  4. Jonas Grumby
    Member
    Posted 3 years ago #

    What does it do if you don't want any sidebar on the page at all?

    I ask because I have a site where I completely removed the sidebar, made the content area wider, and coded in a page-specific sidebar on the pages where they wanted one. On some pages they didn't want any sidebar at all. I'm wondering if this would have been an easier/better solution.

    Thanks

  5. MtnBiker
    Member
    Posted 3 years ago #

    I edited the sidebar.php (theme dependent) as follows for one wide page (named stills:

    <?php
      if (is_page("stills")) {
      echo "<div id=\"right-column-no\">";
      } else {
       echo "<div id=\"right-column\">";
      }
    ?>

    And edited the header.php with a similar statement to use a full width page.
    And edited the stylesheet too. Although I'm not sure what you did; I doubt my solution was easier or better. I took this route because Widget Logic didn't seem to be working for me. For this very simple site, this was not a bad way to go.

    Wide page.

    On another site I used the Atahualpa Theme and it has an option for not showing sidebars on selected pages. This theme gives you lots of control, but you have to remember not to edit the pages, but use the Atahualpa Theme Options interface. For site with potentially more pages, this approach is more robust (compared to editing the theme pages directly).

  6. Jonas Grumby
    Member
    Posted 3 years ago #

    That looks great. All I did was remove the call to the sidebar completely and widen the content area accordingly to take up the full width. Then on pages where they wanted a "sidebar" I just entered the post or page as a two-column table and added my own code to the second column. Much less slick than what you did, but it's done and they're not complaining about it. Thanks for the tip!

  7. Jonas Grumby
    Member
    Posted 3 years ago #

    p.s. If you wanted to have multiple wide pages would the code look like this?

    <?php
      if (is_page("stills")) {
      echo "<div id=\"right-column-no\">";
      } elseif (is_page("anotherwidepage")) {
      echo "<div id=\"right-column-no\">";
      } else {
       echo "<div id=\"right-column\">";
      }
    ?>

    Basically what I'm asking is - can you use elseif to specify another page, or would you use else again, or is neither of those correct?

    Thanks

  8. MtnBikerSoCal
    Member
    Posted 3 years ago #

    I'm not expert on PHP, but I think that is OK.

    But to make it more readable, try an 'or'

    <?php
      if (is_page("stills")) or (is_page("anotherwidepage")) {
       echo "<div id=\"right-column-no\">";
      } else {
       echo "<div id=\"right-column\">";
      }
    ?>

    Untested.

    PS. To be clear 'right-column-no' is a style in the style sheet that looks like this:
    #right-column-no {visibility:hidden}
    and there is another style called by a similar if else:
    #left-column-single {width : 800px;float : left;padding-left:40px;}
    I just took the 300px width of the right column and added it to the 500px width of the left-column format.

    This is not a general solution, that is, it will depend of the particular theme. This is for the 'A Dream to Host' theme.

    And not an easy scheme to maintain if you add pages, either lots of work, or one forgets how they did it. I try to put notes about changes like this in a private or unpublished page. Hoping someone will have a better solution

  9. MtnBikerSoCal
    Member
    Posted 3 years ago #

    On further thought, create a file named, e.g., widepage.php that contains:
    (is_page("stills")) or (is_page("anotherwidepage"))
    then in sidebar.php and other pages that have the logic:
    wide=include (widepage.php);
    and then the logic becomes:

    <?php
      if wide {
       echo "<div id=\"right-column-no\">";
      } else {
       echo "<div id=\"right-column\">";
      }
    ?>

    Then when you add a widepage, only the widepage.php file has to be changed.
    None of this has been tested and I've not used PHP much lately, so test thoroughly or consult references. For example, do variables have special naming such as $wide?
    Also the addition of comments explaining what's going on.

  10. Jonas Grumby
    Member
    Posted 3 years ago #

    Thanks. This is a big help and it gives me ideas for other conditional statements that could be employed.

Topic Closed

This topic has been closed to new replies.

About this Topic