Support » Themes and Templates » Redundant code in index.php ?

  • So I messed around a bit with the theme code to try and make it look better. (Frankly, I like the configurability and the basic newspaper idea, but the layout is such a jumbled mess, nothing really lines up well – it could use some work.)

    Right in index.php the first lines of code are:

    if(get_option($themeoptionsprefix.'_sidebarpos') == 1) {get_sidebar();}
    if(get_option($themeoptionsprefix.'_sidebarpos') != 2 || get_option($themeoptionsprefix.'_sidebarpos') != 1)  {get_sidebar();} ?>

    The second statement alone – if it’s not 2 OR if it’s not 1 – well, isn’t that always true, no matter what? What’s the purpose of this here?

    And together with statement one, you get something like:
    Get sidebar if sidebarpos is 1.
    But also if it’s not 1.
    Oh, and if it’s not 2.

    Isn’t that completely redundant?

    Thing is I’m not a PHP or WP expert, so I’d like to know whether there is some deeper purpose behind it that I just can’t see, or whether it’s just sloppy code.

Viewing 1 replies (of 1 total)
  • Magazine 640 lets you run in either Magazine or traditional blog layout (options 1 or 2 ?)

    In traditional blog layout, there are multiple sidebar positions, and narrow sidebars inside the wide sidebar. The narrow sidebars have multiple positions if used – top, bottom, middle etc. are these the 1,2,3, etc?

    Plus, “if == 1” is an absolute condition and being first it takes precedence, anything that is “1” will not reach the second if statement.

    If something reaches the second if statement, we know it is not “1”, therefore to say !=2 means you are saying >2 essentially.

    The two if statements cover different actions for “1” and “>2”, if it is “2” then either there is no conditional code and the default happens, or the result is covered by an “else” statement.

Viewing 1 replies (of 1 total)
  • The topic ‘Redundant code in index.php ?’ is closed to new replies.