Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Template gallery how to ?

Template gallery how to ?

Hi,

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 ?

It's all good in theory but it's not working :-(

I've taken the liberty of linking the 3 rules here:

http://joomla.6degres.ca/TMP/1.jpg
http://joomla.6degres.ca/TMP/2.jpg
http://joomla.6degres.ca/TMP/3.jpg

Can someone help me figure this out ?

Thanks,

Danny

iDanny
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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:

1 - detect "001_tropical" in the URL. In SUCCEED action, (i) reset all session variables and (ii) set session variable A
2 - detect "002_XXXXX" in the URL. In SUCCEED action, (i) reset all session variables and (ii) set session variable B
3 - detect "003_XXXXX" in the URL. In SUCCEED action, (i) reset all session variables and (ii) set session variable C
4 - detect "004_XXXXX" in the URL. In SUCCEED action, (i) reset all session variables and (ii) set session variable D

5 - detect session variable A, and set the desired template
6 - detect session variable B, and set the desired template
7 - detect session variable C, and set the desired template
8 - detect session variable D, and set the desired template

Hope that helps,
Stephen

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

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Template gallery how to ?

Hi,

Thanks for the quick reply.

Does this mean i am limited to 4 templates ? I plan on having hundreds :-)

Thanks,

Dannny

iDanny
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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:

$session =& JFactory::getSession();
$template = JRequest::getCmd("template"); //a-zA-Z0-9_-.
if ($template != "") {
  $session->set( 'template', $template, 'switcher'); // switcher is an arbitrary name.
}
$template = $session->get( 'template', null, 'switcher');
return $template;

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 Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

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.

You can test if here:
http://www.6degres.ca/index.php?option= … y&id=1

These are 4 of the many templates to come.

Here is the screenshot of my settings:
http://joomla.6degres.ca/TMP/4.jpg

Thanks,

Danny

iDanny
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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 Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Template gallery how to ?

I did as you suggested but the results are the same: the template session changes to the default template once I navigate within the "templated" site.

iDanny
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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 Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

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.

Almost there ;-)


Thanks so much for your guidance !

Danny

iDanny
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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 Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10137
Newest User:
lexispoker1
Members Online:
1
Guests Online:
200

Online: 
liaskas

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked