Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Theming

  1. #1
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Base the whole thing in CSS!

    Then people can edit the css to create differnt themes n' such
    Last edited by the-dream; 03-24-2007 at 10:50 PM. Reason: Ooops Forgot The ' s ' On Theme ' s ' !

  • #3
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I use smarty templating... Everbody has there own favorite or you can just create your own.

  • #5
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You need to assign the variables a name, and then run the template with the variables through your function to parse it.

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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.

  • #8
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #9
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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()

  • #10
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •