Page 1 of 1

Wordpress trick

Posted: Thu Feb 10, 2011 9:06 am
by orvacko
Hi all.
I saw in wordpress index.php this trick :

Sorce code:

Code: Select all

<title>{TITLE}</title>
HTML out:

Code: Select all

Testing blog
- do you know how they did this ? because zhere is no <?php echo .. etc ;)
THX

Re: Wordpress trick

Posted: Thu Feb 10, 2011 9:07 am
by John Cartwright
They use a template engine to parse for "tokens", and replace it with their value.

I.e., a simple example would be

Code: Select all

$your_template = 'hello {name}';

echo str_replace('{name}', 'John Cartwright', $your_template);

Re: Wordpress trick

Posted: Thu Feb 10, 2011 9:17 am
by orvacko
THX man ;) I know that, it only looks easy, but that background of its .. omg