A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearIgnoring superscript in title tags - page 1
User InfoPosts
Ignoring superscript in title tags#1
I work on a database driven website. Most pages' titles are the names of partners we have, and served from a database using php.

For example one page might be called "Experian". The problem is that some of the values for partner names don't work because the values are things like

  $partnername22 = Discover<sup>tm</sup> Magazine

I can't use this for a title because superscript can't show up in a title, and I can't change the value because many other things depend on it. Is there a trick I can pull to make the browser ignore the superscript tags if they are in the title?

posted date: 2008-12-17 09:35:00

Re: Ignoring superscript in title tags#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-17 09:35:01

Re: Ignoring superscript in title tags#3
Not AFAIK, but if you're already scripting out a string from the DB, why can't you script out the same string regex replacing tags (or tag pairs, as you wish) with empty strings?

posted date: 2008-12-17 09:40:00

Re: Ignoring superscript in title tags#4
In a word, no.Ideally you would do $partnername22 = strip_tags('Discover<sup>tm</sup> Magazine'); (or something fancier), but if you can't to that then I'm afraid you're stuck with a Javascript solution.Something like:window.title = window.title.replace(/<sup.*?</sup>/, '');

posted date: 2008-12-17 09:41:00

Re: Ignoring superscript in title tags#5
Regular Expression in PHP that will replace <sup>text</sup> with (text):$title = preg_replace('|<sup>(.*?)</sup>|', '\($1\)', $title);It would be similar to do this in javascript.

posted date: 2008-12-17 10:06:00

Re: Ignoring superscript in title tags#6
It would be very simple (and probably advisable) to use PHP's strip_tags() command to remove all of the html from your string before posting it as a title.

posted date: 2008-12-17 10:12:00

Re: Ignoring superscript in title tags#7
Mike, I think you meant this:$title = preg_replace('|<sup>(.*?)</sup>|', '$1', $title);The way you had it before prints some slashes and parenthesis around the tagged word. Right?pg, you could also just do $title = preg_replace('|<sup>(.*?)</sup>|', '', $title);if you wanted to completely remove the superscripted info from the title.

posted date: 2008-12-17 10:17:00

Re: Ignoring superscript in title tags#8
I don't understand the usage here. How do I use this $title value to remove the supercripted text? now the text of the document is: <title><?php echo $offer22name ?>is a magazine</title> Where do I put the $title value and what do I do with it to make it take out everything in the tags?

posted date: 2008-12-17 11:04:00

Re: Ignoring superscript in title tags#9
In response to Bryan (I can't respond to his for lack of points) I did mean to include the parans so that the result has something distinguishing the text. But the slashes should be removed. So the result looks like: Discover(tm) Magazine It wouldn't look right if it was: Discovertm Magazine

posted date: 2008-12-17 11:21:00

Re: Ignoring superscript in title tags#10
For:<title><?php echo $offer22name ?>is a magazine</title>change to:<title><?php echo preg_replace('|<sup>(.*?)</sup>|', '($1)', $offer22name) ?> is a magazine</title>But like Bryan mentioned, you should use PHP's strip_tags() in this scenario. So:<title><?php echo strip_tags($offer22name) ?> is a magazine</title>

posted date: 2008-12-17 11:26:00

Re: Ignoring superscript in title tags#11
In case you miss the other comment I made, The regexp I used would result in: Discover(tm) Magazine.

posted date: 2008-12-17 11:30:00

Re: Ignoring superscript in title tags#12
@pg, bryan meant that $partnername22 == $title. He reworded it in his post to make it clearer that you are editing the Web page's title, and not the partner's name.

posted date: 2008-12-17 11:31:00

select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.