Template gallery how to ?

I'm launching a Joomla/Artisteer template gallery. In this gallery, I need to link thumbnails to a Joomla site and pass a template identifier.

I purchased this in hopes to solve my issue.

I need to know if this makes sense and if so, why it doesn't work:

1- I setup a 1st rule to detect the template name in the URL and kill any A session cookies.
2- I setup a 2nd rule to route the URL to the template name that's detected in is in the URL
3- I setup a 3rd rule to set an A session cookie that keeps the user is that site

So essentially, a visit to the URL with a template specified should allways forget the previous session, route the visitor to the template and set a new session for the time of his visit ?

Re: Template gallery how to ?

Hi Danny,

Thanks for attaching the screenshots - that's a big help.

In Rule 1, you have specified a domain name of "http://joomla.6degres.ca/001". This field requires only a domain name (joomla.6degres.ca), not the "http://" and the "/001". Therefore this parameter will cause rule 1 to always fail.

The same thing applies in Rule 2. It will always fail.

To use MTP to allow the 4 different templates, I'd suggest the following rules for your setup:

Re: Template gallery how to ?

Ok, good question. The technique above is obviously limited to 4, but with a little PHP coding you can do it differently and not be limited like that.

Can you describe more exactly what you want to achieve? Is it simply that you want to be able to send people to the site with specific URLs, then the site will remember that template for the rest of the session?

In that case, you could do it all in 1 rule and not use the built in session variable support.

The only issue is whether you want to have to edit the rule every time you add a new template. You can avoid this, but it means that you have to trust the value that you're being given in the URL (i.e. trust that that is a valid template).

Ok, so here's the quick way, with not much error checking. Just use the following in a single rule, in the PHP section:

What this will do is look for the ?template=... in the URL, and set the session variable according to that. Then it uses the value of the session variable to set the template (i.e. by returning the name from the code).

The logical next step from here is to do some further checking to see if (1) the template actually exists, and (2) whether it's one that you actually want to expose. Are you likely to want to have some installed templates that you *don't* want people to be able to use? In that case you need to maintain a list of templates that the code above will consult.

Hope that helps,
Stephen

Stephen BrandonMetaMod / Chameleon developerIf you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

Re: Template gallery how to ?

Hi,

What you're proposing is just fine for my current requirements.

I cleared all the rules and created a new one with the only detection being the domain = "6degres.ca" and ot's value contain "template=". I set the success to init a session variable A and added the code you gave me above in the run box.

It doesn't seem to remember the template when I browse menus in the tempate site.

Re: Template gallery how to ?

Hi Danny,

The PHP code I gave should go into the Advanced PHP box rather than the "succeed" action box, though in fact it should probably still work...

I see that you are using domain "6degres.ca". That means that it detects exactly that domain name - and NOT www.6degres.ca. Is that what you want? Unless you are hosting more than 1 domain on the box, and want it to act differently for each domain, there's probably no need to use the domain detection.

Since the URL of the links on the test site point to joomla.6degres.ca, perhaps you want to use "joomla.6degres.ca" as the detected domain?

Cheers,
Stephen

Stephen BrandonMetaMod / Chameleon developerIf you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

Re: Template gallery how to ?

Oh, yes [slaps forehead] I see why.

Remove the check for "template=" from the rule. With that in place, the rest of the rule only gets run if that's in the URL, which isn't what you want.

So I'd recommend that you do the check for joomla.6degres.ca as the domain name, then place the PHP code into the Advanced PHP box at the bottom instead of in the SUCCEED action. (this is important - I realised it won't work in the SUCCEED action PHP box).

That way, the PHP will always get run for each page request on joomla.6degres.ca, and the PHP will detect template=XXX and also the session variable when template=XXX *isn't* in the URL. There won't be any need for anything in the SUCCEED action, as the PHP box will return the template name directly.

I think it'll work this time :-)

Cheers,
Stephen

Stephen BrandonMetaMod / Chameleon developerIf you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

Re: Template gallery how to ?

Ok cool, got it working :-)

Is there a way that the session be remembered for as long as the windows is open (which is already the case) but not be replaced by another window when opened in tabs ? For instance; the visitor clicks on one thumbnails and a new window opens and displays the template (it will stay that way when nacigating too). All good so far. The visitor then goes back into the gallery and selects another template which opens in yet another new window. This just remplaced the old session id from the previous window thus if the visitor goes back to the first template winodow and changes menus, he gets the second template.

Re: Template gallery how to ?

Unfortunately, this is almost impossible to achieve. The only way that you can do this is for every link on the page to include an explicit URL parameter - e.g. &template=XXX.

If you don't do that, then the application can't determine which tab/page was supposed to have which template.

Hmmm... I suppose you can achieve the same sort of thing with SEF URLs. i.e. if there was some way to make the url yoursite.com/XXX/... where XXX was the template name. But that's really hard to do consistently in Joomla.

The other place the template name could go would be a subdomain. I know you were trying to get away from these, but XXX.yoursite.com, YYY.yoursite.com etc would always keep that subdomain name in place, so MetaTemplate could extract that name and use it as the template.

Does that sound like a possibility to you?

Cheers,
Stephen

Stephen BrandonMetaMod / Chameleon developerIf you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod