• Resolved Nessdufrat

    (@nessdufrat)


    Hi !
    I’m trying to set different sidebars according to which page the user is on.
    I did that :

    <?
    if is_page('8')
    {
    function_exists('dynamic_sidebar') && dynamic_sidebar(2)
    }
    if is_page('7')
    {
    function_exists('dynamic_sidebar') && dynamic_sidebar(1)
    }
    endif; ?>

    and on my page.php template,

    <? get_sidebar(); ?>

    I get a parse error, unexpected T string on line 2 on the sidebar.php.

    “Parse error: syntax error, unexpected T_STRING, expecting ‘(‘ “

    Can’t understand what’s wrong. Help would be greatly appreciated !

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Your second “if” should be “elseif” and you should have an else (even if it’s blank).

    <?
    if is_page('8')
    {
    function_exists('dynamic_sidebar') && dynamic_sidebar(2)
    }
    elseif is_page('7')
    {
    function_exists('dynamic_sidebar') && dynamic_sidebar(1)
    }
    else {
    	// blank - do not show a sidebar
    }
    
    endif; ?>

    Thread Starter Nessdufrat

    (@nessdufrat)

    Actually, I did something different because my code was completly false from the beginning.

    Here is the right version :

    <div class="sidebar">
    <?
    if( function_exists( 'dynamic_sidebar' ) )
    {
    	switch ( is_page( $post->ID ) )
    	{
    		case "8":
    		{
    			dynamic_sidebar( 2 );
    			break;
    		}
    
    		case "7":
    		{
    			dynamic_sidebar( 1 );
    			break;
    		}
    	}
    }
    ?>
    
    </div>

    cool! So it works now?

    Thread Starter Nessdufrat

    (@nessdufrat)

    Yeah ?? A friend (C# programmer) helped me write this, and it works like a charm !

    I can’t do anything on my site. I can’t get to dashboard because whenever I type my URL in this comes up.

    Parse error: syntax error, unexpected T_STRING in /home/thescri1/public_html/wp-includes/functions.php on line 1208

    Someone please help!

    Did you change some code in your functions.php file?

    No, it just happened out of nowhere. One day it just didn’t work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Conditional tag and parse error’ is closed to new replies.