|
-
Feb 11th, 2008, 06:51 PM
#1
Thread Starter
Hyperactive Member
Text parsing and replacement. php5
Totally lost on how to do this but figure it's via one or more of the string functions.
Am adding in bbcode tags to an articles management system and so far pretty easy to do bold, underline, strike out, etc.
Having problems getting an article link thing to work.
What I would like to do is tag up titles appearing in articles, then when the article is parsed the software will check if another article exists in the datebase and replace the bbcode with a link to the other article.
Something like
Considering the similarities to Miike's [ m ] Imprint [ /m ] one is left with the only conclusion being ....
So "Imprint" is seen as an article title, due to the [ m ] tag (spaces inserted just in case vB's parser does something with them), when it comes time to display this article, the software takes "Imprint" checks if an article of that name exists in the db, if it does then the software replaces the "[ m ] Imprint [ /m ]" with a link to the "Imprint" article, if it doesn't the [ m ] tags are simply removed. Oh and articles can of course have multiple words in their title.
Hopefully that all make's some sort of sense
Thanks in advance.
-
Feb 15th, 2008, 08:57 AM
#2
-
Feb 17th, 2008, 06:18 PM
#3
Thread Starter
Hyperactive Member
Re: Text parsing and replacement. php5
 Originally Posted by manavo11
What part are you having trouble with? The tag checking? The tag adding to articles? The tag replacement?
The tag replacement with a url link.
-
Feb 17th, 2008, 06:38 PM
#4
-
Feb 17th, 2008, 06:53 PM
#5
Thread Starter
Hyperactive Member
Re: Text parsing and replacement. php5
 Originally Posted by manavo11
Am using the preg_replace function and have bold, italic, and strike-out working but am unsure if I can take the same approach with urls as it will need to search for the title on the database, work out the url extension before converting the tags.
At this stage just toying with the idea, trying to get it to work, and then seeing the impact on a db with a few hundred records.
-
Feb 17th, 2008, 07:09 PM
#6
Re: Text parsing and replacement. php5
You can use the preg_replace_callback() function. You can have your checking code in here. I would advise you do this on input rather than during the display process.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|