onjegolders Posted April 19, 2012 Share Posted April 19, 2012 (edited) Is there a way to echo a URL segment for example to use in the <title> tag? Eg: <title><?php echo $page->title; ?> | <?php echo $input->urlSegment(2); ?></title> The above code was my stab at it but I'm not sure if segments can be called in this way? Sorry, should point out that this is within a header.inc template Edited April 19, 2012 by onjegolders Link to comment Share on other sites More sharing options...
onjegolders Posted April 19, 2012 Author Share Posted April 19, 2012 For my page titles, I have found another way of doing it with the following code: <title>Site Name | <?php if ($page->rootParent->title != $page->title) {echo $page->rootParent->title . " | ";} ?><?php echo $page->title; ?></title> Would still be interested to know if you can echo or use urlSegments in if statements though. Thanks Link to comment Share on other sites More sharing options...
diogo Posted April 19, 2012 Share Posted April 19, 2012 You can do what you want like this: echo '<title>' . ($input->urlSegment2 ? $input->urlSegment2 : $page->title) . '</title>'; 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