Dynamic page title based on URL variables?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zander213
Forum Newbie
Posts: 13
Joined: Mon Aug 23, 2004 1:46 pm

Dynamic page title based on URL variables?

Post by zander213 »

I am setting the title for a drupal site of mine with the following script:

<?php
drupal_set_title($_GET['Foo1'].' '.$_GET['Foo2'].' '.$_GET['Foo3']);
?>

that's working just fine... but I want to include some additional text in the title like this:

"search.php?Foo1=Bar1&Foo2=Bar2&Foo3=Bar3" ... title would be "Bar1 Bar2 Bar3 TEXT"

How can I insert additional text into this output? Can I put an echo in here somehow?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Code: Select all

$title =$_GET['Foo1'].' '.$_GET['Foo2'].' '.$_GET['Foo3']."some of your own text";
echo $title;
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

<?php

$title = (isset($_GET['foo']) ? htmlentities($_GET['foo']) : '');

?>
<html>
<head>
  <title>
  <?php echo $title; ?>
  </title>
</head>

 etc..
Post Reply