Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2007, 09:58 PM   PM User | #1
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
Theming

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.
Forsaken is offline   Reply With Quote
Old 03-24-2007, 10:50 PM   PM User | #2
the-dream
Regular Coder

 
the-dream's Avatar
 
Join Date: Mar 2007
Location: Northamptonshire, UK
Posts: 477
Thanks: 8
Thanked 4 Times in 4 Posts
the-dream can only hope to improve
Base the whole thing in CSS!

Then people can edit the css to create differnt themes n' such
__________________
Branchr Advertising Network

Last edited by the-dream; 03-24-2007 at 10:50 PM.. Reason: Ooops Forgot The ' s ' On Theme ' s ' !
the-dream is offline   Reply With Quote
Old 03-25-2007, 07:33 PM   PM User | #3
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
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?
Forsaken is offline   Reply With Quote
Old 03-25-2007, 08:28 PM   PM User | #4
iLLin
Regular Coder

 
Join Date: Oct 2005
Location: Right Here
Posts: 654
Thanks: 1
Thanked 0 Times in 0 Posts
iLLin is an unknown quantity at this point
I use smarty templating... Everbody has there own favorite or you can just create your own.
iLLin is offline   Reply With Quote
Old 03-25-2007, 08:48 PM   PM User | #5
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
heh, just trying to learn some stuff out, cause i notice that tpl files use

a bunch of html like
Code:
<html>
  <title>{TITLE_NAME}</title>
  <body>
            blablbablabla
  </body>
</html>
and in another file have
Code:
  $something = array("
                         'TITLE_NAME' => 'Something
                            ");
and the {TITLE_NAME} would actually display "Something" which i dont understand how..
Forsaken is offline   Reply With Quote
Old 03-25-2007, 09:15 PM   PM User | #6
iLLin
Regular Coder

 
Join Date: Oct 2005
Location: Right Here
Posts: 654
Thanks: 1
Thanked 0 Times in 0 Posts
iLLin is an unknown quantity at this point
You need to assign the variables a name, and then run the template with the variables through your function to parse it.
iLLin is offline   Reply With Quote
Old 03-26-2007, 02:56 AM   PM User | #7
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
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.
Inigoesdr is offline   Reply With Quote
Old 03-26-2007, 04:55 AM   PM User | #8
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
So if I had {SITE_NAME}, {TITLE_NAME} ect.. in another file (template file)

with an array of

Code:
$something = array('SITE_NAME' => 'YOURISLAND.COM',
                           'TITLE_NAME' => 'MY TITLE'
                           );
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

Code:
foreach($something as $key=>$definition)
{
  // search for {$something} and replace it
}
this seem about right?
Forsaken is offline   Reply With Quote
Old 03-26-2007, 05:28 AM   PM User | #9
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
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()
Inigoesdr is offline   Reply With Quote
Old 03-26-2007, 06:22 AM   PM User | #10
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
alright im having bit of trouble here...

i have

english.lang
Code:
'UPLOAD' => 'Upload Files',
'MANAGE' => 'Manage Files',
'SHARE' => 'Share Files'
grab-template.php
Code:
	$words_arr = array(file_get_contents('language/english.lang'));
	print_r($words_arr);
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

$words_arr[0]

and when you echo that it displays

Code:
Array ( [0] => 'UPLOAD' => 'Upload Files', 'MANAGE' => 'Manage Files', 'SHARE' => 'Share Files' )
how can i fix this problem / go around it
Forsaken is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:28 AM.


Advertisement
Log in to turn off these ads.