Results 1 to 7 of 7

Thread: Template switching based on user rights

  1. #1
    Join Date
    Sep 2009
    Location
    Bucharest, Romania
    Posts
    29

    Question Template switching based on user rights

    Hi,

    One of my clients asked me if i can get the template to change colors automatically after the agents are logged in. He wanna have the main template as it is for anonymous users and members.

    I know it can be done by hard-codding the template files and use the {check_agent } conditional comments.. however, this is probably also the hardest and longest way.. having to duplicate basically all css just for a color change (red will become blue ).

    The other way is to load different templates, and i think this is the simplest way.. so, my question is:

    Is there a simple way , or and add-on already developed that can do that or can be modified to perform that automatically?

    P.S.
    I use O.R. 2.5.8 for this client.


    Thank You in advance.
    Marin
    Last edited by marin; 04-12-2011 at 03:46 PM. Reason: removed some lines

  2. #2
    Join Date
    Sep 2009
    Location
    Bucharest, Romania
    Posts
    29

    Default Re: Template switching based on user rights

    No one with an idea?

  3. #3
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Template switching based on user rights

    Quote Originally Posted by marin View Post
    No one with an idea?
    I don't think any new ideas are still being conceived for OR v2.

    OR is up to v3.1.2 now, you should probably upgrade before the OR v2 forum areas are closed to new posting.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  4. #4
    Join Date
    Sep 2009
    Location
    Bucharest, Romania
    Posts
    29

    Default Re: Template switching based on user rights

    @the_sandking - I understand your point, but right now upgrading from 2.x to 3.x is not an option, unfortunately (the website owner doesn't wanna to upgrade).

    And even if i'll update, i'll just have to ask this question again into the 3.x forums.

    I found how to interogate the database and find out if an user is agent or admin or member, my only problem is that i don't know how to load the correct template after a given result, e.g. :

    Code:
    // get main listings data
            while (!$recordSet->EOF) {
                $agent = $misc->make_db_unsafe ($recordSet->fields['userdb_is_agent']);
                $admin = $misc->make_db_unsafe ($recordSet->fields['userdb_is_admin']);
                $recordSet->MoveNext();
            } // end while
            if($admin=='yes'){
                           
                code to load template 2 here;
                 
            }elseif($agent=='yes'){
    
                code to load template 2 here;
            
            }
             
         code to load template 1 here;
                
        }
    I did searched all over the internet, but my php skills are pretty much zero and i couldn't figure out how to do that.
    Basically i just need some code that will change the path from the one for the default template to another customized path..
    If someone can tell me what code to put instead of "code to load template 2 here" .. i think is not that much to ask..

  5. #5
    Join Date
    Feb 2004
    Posts
    1,085

    Default Re: Template switching based on user rights

    This may work for what you want to do.
    Look in your common.php for this
    Code:
                                    if (isset($_SESSION["template"]))
                                            {
                                                    $config["template"] = $_SESSION["t
    emplate"];
                                            } else {
                                                    $config["template"] = $misc->make_
    db_unsafe($recordSet->fields["controlpanel_template"]);
                                            }
    You see it sets a template based on the SESSION['template']

    try this below that above
    Code:
    // if agent login or admin login
    if ((isset($_SESSION["isAgent"]) == 'yes') || (isset($_SESSION['admin_privs'])) == 'yes') {
        $config["template"] = "TEMPLATEFOLDER"; // the name of the folder you want to use if logged in and is agent  
    }

  6. #6
    Join Date
    Sep 2009
    Location
    Bucharest, Romania
    Posts
    29

    Default Re: Template switching based on user rights

    @alsmith

    mate, you are brilliant
    It worked.

    Than You !


    Marin

  7. #7
    Join Date
    Feb 2004
    Posts
    1,085

    Default Re: Template switching based on user rights

    glad I could help.

Similar Threads

  1. 3.0.2 switching to seo turns off lazuli template
    By OwnerDirectSpain in forum Installation/Configuration Help
    Replies: 31
    Last Post: 07-08-2010, 01:25 PM
  2. Broken template after switching to Linux
    By egubert in forum Templates - Help/Ideas/Discussion (CLOSED)
    Replies: 0
    Last Post: 01-05-2010, 06:12 AM
  3. URL based template switching
    By NovaBurn in forum Templates - Help/Ideas/Discussion (CLOSED)
    Replies: 11
    Last Post: 04-18-2009, 08:28 AM
  4. URL based template switching
    By NovaBurn in forum General Help (CLOSED)
    Replies: 4
    Last Post: 04-17-2009, 10:10 AM
  5. PbFlash TemplateChanger choose template based on agent
    By Andrea80 in forum Addon help, ideas and discussion (CLOSED)
    Replies: 3
    Last Post: 02-20-2007, 01:29 PM

Tags for this Thread

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
  •