Page 1 of 1

Adding new tags and processing them in PHP.

Posted: Wed Oct 29, 2008 4:36 am
by hINTModuleState
Hi evrybody.
This is my first post here and I'm new to PHP. but as I understood it is a very good alternative to the very complex plateform for the Web.

My problem is the following.
Well I do plan to do a static content website, ie publishing only. It is about Chess articles,etc. The only interactivity where I need dynamic code is when to provide users with an editor for content editing then the website receive the entered content and publish it as a new article in the WebSite (after it is stored into a database).

Ok I've already succeded to understand the feasibilty of this as I found editor,etc.

My only problem now is that I want to add a new tag : becuase a chess article contains text+ chess positions.
Now I have a sort of dynamic code in PHP that accepts a poistion string (a string that describes the placement of piecves)
then outputs a HTML code ready to be rendered by the browser and display a sort of chess board poistion,etc.

Now what remains is only to define a sort of new tag in which users enclose their string then have that string processed at server side using PHP code.
It is the same when you access the "Post new topic" interface in this forum and add a quote or code,etc.

My only problem is how I can parse the whole content edited by user, then detect the new tag, capture the insider text, pass it to the function and replace it with the new output ??

Are there any PHP functions that can process that easily ??
Thank you in advance.

Re: Adding new tags and processing them in PHP.

Posted: Wed Oct 29, 2008 4:39 am
by onion2k
str_replace() by the sounds of it. Or maybe a regular expression.

Re: Adding new tags and processing them in PHP.

Posted: Wed Oct 29, 2008 4:52 am
by hINTModuleState
So suppose I have the following text string :

char pUserText[]="This is a text preceding position chess position [FEN]rrrbbbppp[/FEN] This is text after position.";

and suppose the functions that translates the FEN string into HTML is named :

char* translateFENText2HTMLPosition(char* fenText);


So how can I do the algo ?

char* pFinalHTML= doParseUserText(char* pUserText);


doParseUserTex ??

Thank you in advance.