View Full Version : Theming

03-24-2007, 10:58 PM
Well, I'm working on a mini project I took upon my self which will have different languages, themes ect.

What would be the best way to theme, I know cookies and stuff but I want a user friendly template / designing method so others can easily customize / make new templates for this application.

03-24-2007, 11:50 PM
Base the whole thing in CSS!

Then people can edit the css to create differnt themes n' such

03-25-2007, 08:33 PM
well out of curiosity how do tpl files work? how do you transfer a variable from lets say PHP to a tpl file that just gets information using {USER_NAME} or something of that nature?

03-25-2007, 09:28 PM
I use smarty templating... Everbody has there own favorite or you can just create your own.

03-25-2007, 09:48 PM
heh, just trying to learn some stuff out, cause i notice that tpl files use

a bunch of html like


and in another file have

$something = array("
'TITLE_NAME' => 'Something

and the {TITLE_NAME} would actually display "Something" which i dont understand how..

03-25-2007, 10:15 PM
You need to assign the variables a name, and then run the template with the variables through your function to parse it.

03-26-2007, 03:56 AM
Presumably you would add all of your php variables to an array(like you did), then search for text in the template with the same name, and then replace it with the value from your array using a custom function or split the array and use preg_replace() to do both of the last steps at once.

03-26-2007, 05:55 AM
So if I had {SITE_NAME}, {TITLE_NAME} ect.. in another file (template file)

with an array of

$something = array('SITE_NAME' => 'YOURISLAND.COM',

I would then I would have to make a function or something that would run at the start with like a loop or something that has

foreach($something as $key=>$definition)
// search for {$something} and replace it

this seem about right?

03-26-2007, 06:28 AM
preg_replace() will take arrays for search patterns & replacements for them so you wouldn't need a loop. If you already had the array you would probably want to use array_keys() & array_values() to split the array for preg_replace()

03-26-2007, 07:22 AM
alright im having bit of trouble here...

i have


'UPLOAD' => 'Upload Files',
'MANAGE' => 'Manage Files',
'SHARE' => 'Share Files'


$words_arr = array(file_get_contents('language/english.lang'));

whats happening is that it thinks the file_get_contents is one entire string which it is making and then sends it to the array so there is one thing in the array


and when you echo that it displays

Array ( [0] => 'UPLOAD' => 'Upload Files', 'MANAGE' => 'Manage Files', 'SHARE' => 'Share Files' )

how can i fix this problem / go around it