Jump to content

Recommended Posts

Posted (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 by onjegolders
Posted

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

Posted

You can do what you want like this:

echo '<title>' . ($input->urlSegment2 ? $input->urlSegment2 : $page->title) . '</title>';

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...