tekno Posted August 15, 2015 Share Posted August 15, 2015 hi i use if condition for $page->template=='templatename' but after 2. if condition codes get error codes are the same but when i add 2. condition gets an error "syntax error, unexpected end of file" <?php //gallery lightbox css if ($page->template=='photos'){?> <link rel="stylesheet" href="<?=$config->urls->templates;?>assets/css/lightbox.css"> <?php} ?> this works fine but <?php //gallery lightbox css if ($page->template=='photos'){?> <link rel="stylesheet" href="<?=$config->urls->templates;?>assets/css/lightbox.css"> <?php} ?> . . . . .. . . . . .. . . . .. . . . . . . .. . . . . . . .. . . . .. <?php //products calendar css if ($page->template=='products'){?> <link rel="stylesheet" href="<?=$config->urls->templates;?>assets/css/calendar.css"> <?php} ?> whats wrong? 2.condition for same operator ($page->template) using different? Link to comment Share on other sites More sharing options...
tpr Posted August 15, 2015 Share Posted August 15, 2015 Perhaps you got an unclosed condition/loop elsewhere in your code, or the file was uploaded only partly. I see no syntax error in the chunk above. Link to comment Share on other sites More sharing options...
tekno Posted August 15, 2015 Author Share Posted August 15, 2015 no i controlled it, when i remove 2. condition it works fine Link to comment Share on other sites More sharing options...
k07n Posted August 17, 2015 Share Posted August 17, 2015 Just insert space after php: <?php } ?> And I think it is good to use alt syntax in your examle, it is easier to read: <?php if (condition): ?> <div>bla-bla-bla</div> <?php endif; ?> Link to comment Share on other sites More sharing options...
tekno Posted August 17, 2015 Author Share Posted August 17, 2015 thanks K07N its not giving error with this codes <?php if ($page->template=='products'): ?> <link rel="stylesheet" href="<?=$config->urls->templates;?>assets/css/calendar.css"> <?php endif; ?> but its not work too i want to add some extra metas into included _header.php why didnt i succeed? or how its easier to include? Link to comment Share on other sites More sharing options...
diogo Posted August 17, 2015 Share Posted August 17, 2015 $page->template returns the template object, wish is not equal to the string 'products'. Try this instead: if ($page->template->name == 'products') Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 17, 2015 Share Posted August 17, 2015 $page->template returns the template object, wish is not equal to the string 'products'. Try this instead: if ($page->template->name == 'products') That's wrong. The template object does have a __toString() method, which returns the name, therefore comparing without type check does work. // For a page using a template named "products" $page->template == "products" // true $page->template === "products" // false (object !== string) $page->template->name === "products" // true (string === string) 1 Link to comment Share on other sites More sharing options...
tekno Posted August 17, 2015 Author Share Posted August 17, 2015 ahh sorry codes working but im searching printed codes on wrong place thanks guys btw if (condition): //do elseif (condition): //do another endif; usage is really easier thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now