Create snippet or token like command to change title of page

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
bobbkc
Forum Newbie
Posts: 6
Joined: Sat Aug 13, 2011 4:27 pm

Create snippet or token like command to change title of page

Post by bobbkc »

I have been looking on this site for an answer to this question with no results. I am probably wording the search wrong. I am not a coder but I have created several php sites and understand about enough code to make me dangerous. I am trying to create a snippet or token like command that I can automatically change a title of a page based on the url of that page. I have several pages that use the same template but I need to be able to change the title and even the meta tages with something like [ArtistName] as a type of token to insert into the title and meta tag area. An example would be http://www mysite.com/artist-name/ResultArtist.php?artist=John+Smith&pid=201. This is not a real url but just an example. I would like to automatically display the title and meta description for this page as John Smith. There would be 500 - 600 artists pages all using the same template so this would be a great help. I know how to echo the current url (code plus the <?php
echo curPageURL();?>) to a place on the page but I don't know how to create this snippet or token I am looking for. I am probably stating several different terms here but I don't know if I should try and create a snippet or some kind of token or what. Please help.
Thanks, Bob.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Create snippet or token like command to change title of

Post by AbraCadaver »

For starters:

Code: Select all

echo '<title>' . htmlentities($_GET['artist']) . '</title>';
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
bobbkc
Forum Newbie
Posts: 6
Joined: Sat Aug 13, 2011 4:27 pm

Re: Create snippet or token like command to change title of

Post by bobbkc »

Worked! thanks for the help. Bob.
Post Reply