0
Welcome Guest! Login
0 items Join Now

User template choices?

    • hammer's Avatar
    • hammer
    • Rocketeer
    • Posts: 86
    • Thanks: 0

    User template choices?

    Posted 18 years 2 months ago
    • I have a couple of templates available for vistiors to choose from, however, when a user, or member chooses the template that isn't the site's default template, it will always revert back to the default template after a short period of time.

      Is there an option available that I'm missing to allow users and or members to choose their own default template - without causing the site's default template to take over?
    • GollumX's Avatar
    • GollumX
    • Elite Rocketeer
    • Posts: 2817
    • Thanks: 0

    Re: User template choices?

    Posted 18 years 2 months ago
    • what do you mean by "after a short period of time."?

      you're either referring to sessions. which don't last long at all, and often ends when the user leaves the site, or cookies, which i believe are stored for 20days.

      The way to get around all that would be to store the members template choice in the users table in the db, but i'm sorry that's quite beyond my skill level.

      someone else here might be able to help, but IMO the joomla forum is the correct place for this question, and since it's such a sought after feature, there may already be a solution.

      William, if you find the answers you're looking for elsewhere, please post back here. I'd love this feature in one of my sites as well. :)
    • Say no to Internet Explorer 6.
      twitter.com/mark_up
    • hammer's Avatar
    • hammer
    • Rocketeer
    • Posts: 86
    • Thanks: 0

    Re: User template choices?

    Posted 18 years 2 months ago
    • Thanks for the reply GollumX.

      Short time? Sometimes a few minutes, and sometimes much longer - it seems to be connected with activity on the site. Lots of page views and the chosen template will remain - take a bit of a break, and the next page viewed will revert back to the default.

      If I find anything, I'll post here. If someone has a fix, please post away.
    • hammer's Avatar
    • hammer
    • Rocketeer
    • Posts: 86
    • Thanks: 0

    Re: User template choices?

    Posted 18 years 2 months ago
    • I found the following piece of code in includes/joomla.php it looks like it may hold the answer to the question:
      // TemplateChooser Start
                     $jos_user_template       = strval( mosGetParam( $_COOKIE, 'jos_user_template', '' ) );
                     $jos_change_template     = strval( mosGetParam( $_REQUEST, 'jos_change_template', $jos_user_template ) );
                     if ($jos_change_template) {
                          // clean template name
                          $jos_change_template = preg_replace( '#\W#', '', $jos_change_template );
                          if ( strlen( $jos_change_template ) >= 40 ) {
                               $jos_change_template = substr($jos_change_template, 0 , 39);
                          }
                          
                          // check that template exists in case it was deleted
                          if (file_exists( $mosConfig_absolute_path .'/templates/'. $jos_change_template .'/index.php' )) {
                               $lifetime        = 60*10;
                               $cur_template   = $jos_change_template;
                               setcookie( 'jos_user_template', "$jos_change_template", time()+$lifetime);
                          } else {
                               setcookie( 'jos_user_template', '', time()-3600 );
                          }
                     }
                     // TemplateChooser End
    • hammer's Avatar
    • hammer
    • Rocketeer
    • Posts: 86
    • Thanks: 0

    Re: User template choices?

    Posted 18 years 2 months ago
    • After I found the above snip of code, I did some googling with portions of the above code and found what appears to be a fix to this issue:

      Find the following
      $lifetime = 60*10;

      And change to this:
      $lifetime = 60*60*24*365*10;

      The lifetime variable is now set for 10 years - and since I made the change, my template of choice has not reverted back to the site default.

      I don't know if this change will have any effect on variable templates chosen for menu items - I don't make use of that feature, but I don't suspect it will.

      In any event, so far so good, but it will be at least 10 years before we know if this is a long term fix ;D
    • GollumX's Avatar
    • GollumX
    • Elite Rocketeer
    • Posts: 2817
    • Thanks: 0

    Re: User template choices?

    Posted 18 years 2 months ago
    • GollumX wrote:
      you're either referring to sessions. which don't last long at all, and often ends when the user leaves the site, or cookies, which i believe are stored for 20days.

      what was i thinking. too much coffee i think (it was 2.00am when i wrote that by the way)

      -joomla tracks sessions using cookies
      -default session length is 900seconds (configurable in backend global configuration)

      Good to hear you found a fix.

      :) @ 10yrs. i think the browsers purge cookies older then 20days?30days? something like that. correct me please if i'm wrong.
    • Say no to Internet Explorer 6.
      twitter.com/mark_up

Time to create page: 0.061 seconds