PDA

View Full Version : BASIC PHP Template using SSI?



insan99
21 Feb 2006, 05:04 PM
How do I make a php template that controls variables for every page that uses it?

Example: Global Artist Profile Template

<% Name %> <br/>
<% Picture %> <br/>
<% Bio %> <br/>
<% Audio %> <br/>
<% Lyrics %> <br/>
<% External Links %> <br/>
<% Artist Page Ad %> <br/>

-----Becomes-----

MC Tech
This guy is blah blah...
Song 1, Song 2...
Lyric 1, Lyric 2...
www.link1.com, www.link2.com
"Buy CDs from amazon.com!"

I need to be able to add <% Videos%> for example down the road to the global template and it effects every page that uses it.

A. How do you do this?

B. Do I have to store the data in a mySQL database?

Thanks.

hosttds
21 Feb 2006, 09:25 PM
you can use the pregreplace syntax to do that...



<?php
// This is taken from somewhere and written in PHP
$str = 'Hello, [name]
This is my phone number [phone]-[number]';

// Those are the variables to be replaced with inside []
$name = 'Mike';
$phone = '+39';
$number = '555...';

$msg = preg_replace("/\[(\w+)\]/e", "\$\\1", $str);
print $msg;
?>