How to Replace a String in an HTML ex: __foo__
Posted: Thu Jul 19, 2007 4:20 pm
There's this Script (Dolphin Smart Community Builder) which is an Online Community written in PHP. They use HTML Pages but most of the Script is pure PHP. When you need to change the layout of the Member's Profile, you need to edit the Profile.php of that Script, Also the HTML "page_7.html". But I saw something interesting on that Script and I would like to know how it's done.
When Browsing for Profiles let's say we open: http://www.domainname.com/profile.php?ID=3, the Profile.php launches the Page_7.html together with the Profile.php, but the Page_7.html is 80% written with strings like this: __thumbnail__, __pagetitle__, __sex__, __age__. Those strings are replaced by the Profile.php.
Let's say we would like to place the Members ID somewhere in the Profile View, We need to Place __IDM__.
__IDM__ calls this:
and that calls the function UserIDM();
which is:
And it returns the ID, let say #3.
That's a function I added, If you need to place a string on the HTML of Page_7.html let say" __whatever__", you just need to add this to the PHP
and the function you want that to do:
and you're ready to Go, there's no need to add a str_replace etc.
But that only works if you place the:
before this small string:
How does the Script changes any __thing__ you place to a function that will return something maybe from the database without the need of making a srt_replace to __allthis__...
There's some function that does exactly this and not the str_replace that echoes a value or something?
You can go here and see the Full Profile.php:
http://svn.freedatinghost.com/doltree/f ... rev=0&sc=0
And the Page_7.html
http://svn.freedatinghost.com/doltree/f ... rev=0&sc=0
When Browsing for Profiles let's say we open: http://www.domainname.com/profile.php?ID=3, the Profile.php launches the Page_7.html together with the Profile.php, but the Page_7.html is 80% written with strings like this: __thumbnail__, __pagetitle__, __sex__, __age__. Those strings are replaced by the Profile.php.
Let's say we would like to place the Members ID somewhere in the Profile View, We need to Place __IDM__.
__IDM__ calls this:
Code: Select all
$_page_cont[$_ni]['IDM'] = UserIDM();which is:
Code: Select all
function UserIDM()
{
global $ID;
$THEIDM = "$ID";
return $THEIDM;
}That's a function I added, If you need to place a string on the HTML of Page_7.html let say" __whatever__", you just need to add this to the PHP
Code: Select all
$_page_cont[$_ni]['whatever'] = whatever();Code: Select all
function whatever()
{
$anythingHere = "";
}But that only works if you place the:
Code: Select all
$_page_cont[$_ni]['whatever'] = whatever();Code: Select all
PageCode();There's some function that does exactly this and not the str_replace that echoes a value or something?
You can go here and see the Full Profile.php:
http://svn.freedatinghost.com/doltree/f ... rev=0&sc=0
And the Page_7.html
http://svn.freedatinghost.com/doltree/f ... rev=0&sc=0