Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: PHP Template Switcher

  1. #11
    Join Date
    Dec 2003
    Posts
    410

    Default

    A few points

    I could be reading the comments incorrectly, but it seems there is a misunderstanding on how the php switcher works. The template will change only if a user selects a different template. When a new template is selected a cookie is created or updated on the user's computer. The default will come up for the next user. The user can change back to the default or any other template available.

    I checked out RealtyOne's code and was not able to get it to work, I am sure I could eventually. In working with the code I realized that all template directories come up in the select box even the templates I may not want to make available. A drop down box listing all the templates as options will work with the php switcher.

    I like the idea of adding language preference to the php switcher. I live in So Florida where Spanish is prevalent and this would be convenient.

    I can envision drop down boxes for both template and language preferences put into the user_top or user_bott html where they will be available to all pages. The drop down menus can be a separate file or part of a db so that any changes will be available to all templates.

    I think would it be better to ad the changer into a user signup and then in his db section.
    When he changes the template his design that he wants to see comes from the db.
    It would depend on what your purpose is. If you want users to have a quick way to view all the templates you are giving or selling then leave it available for all users. If it is for a site that users will likely sign on and return to then allowing only members a preference, as the nuke programs do, may be a good idea.

    More and more I see OR taking on content management qualities.

  2. #12
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    I may also be reading something wrong here
    i think Alberts looking at a default template setup for each agent?
    i like the idea.. for sites with alot of agents and i dont see that it would be a hard thing to do.

    This code is user/guest/agent/ whoever specific.
    On entry they select what they prefer cookie is written that is now their template instead of the default.

    frobn:
    Sorry i did say i hadnt tested it actually i didnt even open it in a browser window. Been a bit busy but i will try to make time and put it all together. It is only a matter of setting the form correctly so that the template is entered the way the coookie wants to recieve it.

    all templates are offered:
    yes it isnt selective.. but if a template is not available would it be on a live site? could allways change it to an admin option. where they get to select what templates will appear in the select. ..(more database).
    My dev-CMS uses this same method(select) for template selectionbut it is only an admin option i like the idea of people selecting their own

  3. #13
    Join Date
    Sep 2003
    Location
    London UK
    Posts
    1,654

    Default

    hi RealtyOne

    If your site does not contain the hidden copywrite please do not seek help from me I WILL NOT GIVE IT!

    Sorry i removed it when testing a stats program.
    http://www.open-realty.org/phpBB2/vi...ighlight=stats

    Some thing to do with headers it did not like. I will have to change it to a new one that works without moving it.

    Love OR 8)

  4. #14
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    :lol: @albert... Was not directed at anyone inparticular. It hjust seems that 80% of people the first thing they do is find and remove the copywrite and it annoys me. I had a request for assistance from 3 people yesterday all with it missing. so i changed my signature

    I have altered the copywrite in my own sites so that the doc type line is the first thing on the page.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    do this by simply placeing the line in a echo above the current commented copywrite.

    to the best of my knowlege this has only ever effected the ability for the page to be complient but it may intrude elsewhere.

    My Improved copywrite: Includes doctype less code neater layout in source.
    Code:
    // Deleting the comment below is violation of the GPL
    	// You get this for free... all we ask for is a little hidden credit
    	echo '	<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">
    	<!-- SCRIPT CREDITS AND COPYWRITE INFORMATION -->
    	<!-- This tool is Open Source and released under the GPL -->
    	<!-- powered by Open-Realty http&#58;//www.open-realty.org. Copyright 2003-->
    	<!-- This product is an approved fork of -->
    	<!-- OpenListings by jon roig @ http&#58;//jonroig.com Copyright 2002. -->';

  5. #15
    Join Date
    Dec 2002
    Posts
    1,883

    Default

    Quote Originally Posted by RealtyOne
    :lol: @albert... Was not directed at anyone inparticular. It hjust seems that 80% of people the first thing they do is find and remove the copywrite and it annoys me. I had a request for assistance from 3 people yesterday all with it missing. so i changed my signature

    I have altered the copywrite in my own sites so that the doc type line is the first thing on the page.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    do this by simply placeing the line in a echo above the current commented copywrite.

    to the best of my knowlege this has only ever effected the ability for the page to be complient but it may intrude elsewhere.

    My Improved copywrite: Includes doctype less code neater layout in source.
    Code:
    // Deleting the comment below is violation of the GPL
    	// You get this for free... all we ask for is a little hidden credit
    	echo '	<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">
    	<!-- SCRIPT CREDITS AND COPYWRITE INFORMATION -->
    	<!-- This tool is Open Source and released under the GPL -->
    	<!-- powered by Open-Realty http&#58;//www.open-realty.org. Copyright 2003-->
    	<!-- This product is an approved fork of -->
    	<!-- OpenListings by jon roig @ http&#58;//jonroig.com Copyright 2002. -->';
    Where is that notice at?
    I change so much I may have removed that too by accident, so if mine is gone I do not even know.

    Where, what file?

  6. #16
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    TO ALL INTERESTED:

    The following is working code for useing the select box method to allow users to set the template to suit themselves.
    As noted by frobn this allows loading of ALL templates from the template directory. if you dont want it used remove it from the template directory.

    The select box.

    Can be placed anywhere you want within the template files.
    Must be available on all templates.

    Code:
    	<?php
    //Code to get template folder names into a select box
    echo '<form action="switcher.php">
       '.$lang&#91;'select_theme'&#93;.'
       <br>
       <select name="set">
       ';
       $template_directory = "./template";
       $template = opendir&#40;$template_directory&#41; or die&#40;"fail to open"&#41;;
       while&#40;!&#40;&#40;$design = readdir&#40;$template&#41;&#41;===false&#41;&#41;&#123;
            if&#40;is_dir&#40;"$template_directory/$design"&#41;&#41;&#123;
            if &#40;$design =='.'&#41;&#123;
            &#125;elseif &#40;$design =='..'&#41;&#123;
            &#125;else&#123;
               echo '<option value="'.$design.'">'.$design.'</option>';
            &#125;
         &#125;
    &#125;
    echo '</select><input type="submit" name="submit" value="go"></form><br>';
       closedir&#40;$template&#41;;
       //End of code to get template folder names into a select box
      ?>
    Switcher.php
    This is a new page. Create it and place it in your main Open-Realty directory.
    This has slight change made from original so that it auto fills the site address.
    You may need to change the default template to suit your own needs.

    Code:
    <?php
    $set = $_GET&#91;'set'&#93;;
    $set = preg_replace&#40;'#&#91;^a-zA-Z0-9_-&#93;#', '', $set&#41;;
    setcookie &#40;'site_template', $set, time&#40;&#41;+31536000, '/', $config&#91;baseurl&#93;, '0'&#41;;
    header&#40;'Location&#58; '.$_SERVER&#91;'HTTP_REFERER'&#93;&#41;;
    ?>
    Common.php [FILE ALTERATIONS]
    The following must be in your common.php at the same place your current template system is placed.

    Code:
    ///////////////////////////////////////////////////
       // setup to change templates
    
       // set default template
    
       //get cookie if  it exists
            $template= $HTTP_COOKIE_VARS&#91;"site_template"&#93;;
       //set default
        if&#40;$template=="" &#41;&#123;
            $template = "vertical-menu";  // replace default_template with your default template
            &#125; 
       //set template directory
            $template = "/template/".$template;
    
       // set template path
       $config&#91;template_path&#93; = $config&#91;basepath&#93;.$template; // leave off the trailing slashes
       $config&#91;template_url&#93; = $config&#91;baseurl&#93;.$template; // leave off the trailing slashes
    ///////////////////////////////////////////////////
    you must comment all current template information as shown here in red
    /*
    // TEMPLATE DATA
    //$config[template_path] = $config[basepath].'/template/generic'; // leave off the trailing slashes
    //$config[template_url] = $config[baseurl].'/template/generic'; // leave off the trailing slashes
    $config['template_path'] = $config['basepath'].'/template/generic'; // leave off the trailing slashes
    $config['template_url'] = $config['baseurl'].'/template/generic'; // leave off the trailing slashes
    */
    Thats it your done.
    If everything has gone right your site looks and works the same as allways. with the addition of a select box at the point you chose to display it.
    When a selection is made the page will refresh to the same page but with its new look. A cookie ha been written to your computer that will keep this look for you.

    Credit to frobn for a great idea

    Enjoy.

  7. #17
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    Please note that this mod has been tested on a standard installation and works fine.
    The above post has been placed in the mods forum please continue this thread there thanks.

  8. #18
    Join Date
    Sep 2003
    Location
    London UK
    Posts
    1,654

    Default

    Quote Originally Posted by RealtyOne
    Untested. Use at your Own risk.

    Add to language file
    Code:
    $lang&#91;'select_theme'&#93; = "Please select your Theme";
    Place where template selector is wanted.
    Code:
    //Code to get template folder names into a select box
    echo '<form action="switcher.php">
    	'.$lang&#91;'select_theme'&#93;.'
    	<br>
    	<select name="set">
    
    ///// remove this code
     ';
    ////end
    
    
       $template_directory = "./template";
       $template = opendir&#40;$template_directory&#41; or die&#40;"fail to open"&#41;;
       while&#40;!&#40;&#40;$design = readdir&#40;$template&#41;&#41;===false&#41;&#41;&#123;
            if&#40;is_dir&#40;"$template_directory/$design"&#41;&#41;&#123;
            if &#40;$design =='.'&#41;&#123;
            &#125;elseif &#40;$design =='..'&#41;&#123;
            &#125;else&#123;
               echo '<option value="'.$design.'">'.$design.'</option>';
            &#125;
         &#125;
    &#125;
    echo '</select></form><br>';
       closedir&#40;$template&#41;;
       //End of code to get template folder names into a select box
    The last code could also be made as a function to save having so much code on a template page i guess but this should work

    Note: The select system may be a little fussy about folder names so for that reason it pays to not attempt to use folders with spaces or weird charactors in the name
    Hi

    please remove the
    ';

    to make it work..


    Big Thanks You Ryan

  9. #19
    Join Date
    Jan 2004
    Location
    Minnesota
    Age
    35
    Posts
    166

    Default

    just a question why are you storing them as a cookie? Why not use a session variable and a cookie? That way you can let users set there template that have there cookies restrictred.

  10. #20
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    //Code to get template folder names into a select box
    echo '<form action="switcher.php">
    '.$lang['select_theme'].'
    <br>
    <select name="set">

    ///// remove this code
    ';
    ////end


    $template_directory = "./template";
    $template = opendir($template_directory) or die("fail to open");
    while(!(($design = readdir($template))===false)){
    if(is_dir("$template_directory/$design")){
    if ($design =='.'){
    }elseif ($design =='..'){
    }else{
    echo '<option value="'.$design.'">'.$design.'</option>';
    }
    }
    }
    echo '</select></form><br>';
    closedir($template);
    //End of code to get template folder names into a select box
    Maybe i am blind or dumb or even both But if you remove the echo closing ( '; ) where is it that it closes instead?
    If it works for you without it thats fine it concerns me very little since i dont use it i am asking only as intrest. i have learnt that if you open something you must also close it so since that is obviosly the end of the echo where is it closeing once removed

    ITP: I didnt write the mod i only made a few changes to it to make template knowledge automatic for the scripts insead of having to do so manually but yes sessions would be a better method, i am sure no-one will mind if you rewrite it

Similar Threads

  1. Template Changer
    By RealtyOne in forum Mods (CLOSED)
    Replies: 47
    Last Post: 05-26-2005, 03:23 PM
  2. Generic Template Prob still there in 1.1.4
    By Anonymous in forum HELP (CLOSED)
    Replies: 3
    Last Post: 10-23-2003, 04:17 PM
  3. Fixed Width Template - Left Align
    By chemaster in forum HELP (CLOSED)
    Replies: 1
    Last Post: 07-14-2003, 05:06 AM

Bookmarks

Posting Permissions

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