Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter mtnbikersocal

    (@mtnbikersocal)

    Thank you. Looks like a winner.

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

    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

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

    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!

    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

    Thread Starter mtnbikersocal

    (@mtnbikersocal)

    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

    Thread Starter mtnbikersocal

    (@mtnbikersocal)

    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.

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Do not display a specific Widget for a specific page’ is closed to new replies.