Author Topic: Switching Joomla template on different shopping pages or different users/langs  (Read 24133 times)

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
I've just released a new component for Joomla that allows you to switch Joomla template based on things like component, user, language, domain name, GeoIP, etc.

The component is Chameleon, http://www.metamodpro.com/chameleon/chameleon

I want to add functionality for it to directly address VirtueMart issues. I figure that there are plenty of VirtueMart admins that would like to be able to switch the overall Joomla template on different VM pages, or for different shopper groups, or any other kind of thing.

So my question is: what sort of features would you like to have?
Under what circumstances would you love to be able to switch to a different template?
- front-end language?
- browser's language?
- domain/subdomain?
- browser type? (e.g. a completely different template for IE users)
- particular VM pages? (e.g. flypage, category listings, checkout, shipping, etc)
- previous history of a logged-in shopper (e.g. previous order history, or country etc) ?
- anything else?

I don't want to spend time building stuff that no-one wants to use, so your feedback will be valuable.


Chameleon comes in 2 flavours - Lite, where you have to code your own rules in PHP, and the full version that has lots of built-in rules like date/time, GeoIP, categories/sections, article id, user groups, user ids, browser type, etc.

Looking forward to feedback,
Stephen Brandon
www.metamodpro.com
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27637
  • Always on vacation
    • Jenkin Hill Internet
I can already see a use for this by VirtueMart users. When different templates are used for the "home" page and the main site at the point of checkout in VM the template switches back from main site to home. Although there is a fix for this happening on Joomla 1.5 this is not ideal( http://forum.virtuemart.net/index.php?topic=34989.0 )

I will have to try it out - although I don't usually switch site templates.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.11 10252 on Joomla 3.9.14 PHP 7.0.33

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Right, I heard about that issue. I'll take a look and see what recipe could be appropriate. Thanks for the feedback. It's probably going to be easy to code.
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
OK, before I build this in to the extension (perhaps as a global preference?), can I get some people to test this out and report back?

Instructions:

1 - download and install ChameleonLite from http://www.metamodpro.com/chameleon/download
2 - create a new Chameleon rule and give it a name
3 - paste the following into the main PHP box, and save it
4 - test out the VM page that was jumping back to the old template. Is this behaviour fixed now?

Code: [Select]
$method = strtolower($_SERVER['REQUEST_METHOD']);
$uri = JURI::getInstance();

if ($method == "post" && substr($uri->_uri,-10) == '/index.php'
 && @$_POST['option'] != '') {
  $newuri = $uri->_uri . '?option='
   .  htmlentities(@$_POST['option'],ENT_QUOTES,'UTF-8')
   . '&Itemid='
   . htmlentities(@$_POST['Itemid'],ENT_QUOTES,'UTF-8');
   $uri->parse($newuri);
}

This works for me on my test site.

On my setup, VM is attached to a menu item so it would be good for someone to test when VM is *not* on a menu item.

I've tested it with built-in SEF both on and off and it's fine with both. It would be good to test with other SEF extensions as well.

Hope this helps other people... this is a good solution in the sense that it does not require hacking any core files, and *should* also fix up any other components that do post requests to plain old "index.php". It's also "sticky" in that any other part of the system that calls JURI::getInstance() will pick up the "fixed" version of the URL and variables.

Once I have some more feedback from people testing it under different conditions I'll put it into the free version of Chameleon as an option.
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

baggiesmad

  • Jr. Member
  • **
  • Posts: 308
ill give this a go over the weekend. thanks

Eden

  • Beginner
  • *
  • Posts: 14
I have tested this and found it also to be working on my virtuemart to some degree, i have a rather unique case where i need multiple templates (4) and am willing to do whatever testing needed to help out with the increased production of this component.

While this is working with 2 templates i am actually running 4 differnt templates:

Basically the first template is a landing page, which links to four other templates (for a business running a conglomerate of similar themed business's.)

each of these has products and sales in it, if i use this code it removes the possibility to use some templates.

Im sure there must be some way to do this after reading this thread and other threads i can see the solutions for this have come some way now, i would rather not hack the joomla  core or the vm core and love the idea of this component being the solution. My coding is very poor and if someone could give me a hand with this it would be most apprecaited. Willing to do whatever needed to get this up and running! you can email me at edenb83AThotmail.com if you need a direct line add that to msn.

THanks guys love your work!

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Hi Edzz83,

Can you be a bit more specific about how you want the different templates applied to your site?

e.g.
- do you have 4 different menu items pointing to the 4 different shops, and you want a different template for each?
- or do you want a different template for each "category" of products in the single shop?

I guess I don't understand the sentence "the first template is a landing page, which links to four other templates (for a business running a conglomerate of similar themed business's.)".

Also I don't get what you mean by "if i use this code it removes the possibility to use some templates". Chameleon (formerly MetaTemplate) will give you all sorts of options for your site - if you can describe what you're after it's likely that you can set it up with Chameleon.

Cheers,
Stephen
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

Eden

  • Beginner
  • *
  • Posts: 14
Thanks for your prompt reply. Im sure there is someway to do this im still trying to wrap my head around metatemplate. Let me explain the my setup a bit more precisely.

Joomla has 4 templates in total installed and one installation of Virtuemart, with 2 seperate menus setup.

The first default template is linked to its own menu with just one default item in it, this is the first page you see when you goto the site, basically this is just a blank template. It shows a single article which links to 3 other menu items in the second menu.

Each of those links and their child items are assigned their own template, giving the illusion of 3 seperate sites. Each on of these menu items has a child which is linked to its own category in the shop, which when clicked on show the sub categories for that specific item. Below is a basic menu tree.


         { EA ENERGY     --> Products
EA GROUP { EA WATER      --> Products
         { EA CONSTRUCTION  --> Products

when i goto for instance ea energy, and then products and try to view one of the sub categories, the content appears in the ea water template.

when i applied your fix (i probably went the wrong way about doing it im not sure) but i found that the landing (ea group) would no longer show, and it would come up with the ea energy first up but the categorys would view fine and you could goto water and view its category fine also.

Please check your PM as i will provide you with a login for further clarification. Its one of those , hard to explain things ;)

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Thanks for the details and more explanation, will take a look at that in the next 24 hours.
Cheers,
Stephen
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

Eden

  • Beginner
  • *
  • Posts: 14
Thanks mate, your help is much appreciated!

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Found a bug in VM that was part of the cause of one of the problems on that site:

http://forum.virtuemart.net/index.php?topic=65719.msg217326

This is to do with inconsistent Itemids, when you have more than one menu link to the VM component.
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

Eden

  • Beginner
  • *
  • Posts: 14
Your a genius ;) been racking my brain over this one for some time!!! sooo much appreciated. Still have further testing to go now hopefully it holds the template through the shopping process also as i hear others have issues with this too.

Cheers for the help!

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
So far we're dealing with 2 different issues with respect to "holding the template through the shopping process".

The first one is regarding what happens to the template when you submit a form in the shopping cart, and when you have allocated a specific template to the front page. This is the one addressed with Chameleon plus the snippet of code earlier in this thread. I'm still hoping to hear back from anyone who has tried this out and can confirm that it solves this problem on their site.

The second one is what I wrote about on http://forum.virtuemart.net/index.php?topic=65719.msg217326 which is concerned with wrong itemids, when you have a direct menu link to a particular category, then that category has links to subcategories. The subcategory links end up with the wrong Itemid, unless you use the fix in that post.

Happy to help :)
Stephen
Regards,
Stephen Brandon
MetaMod and MetaTemplate author

Eden

  • Beginner
  • *
  • Posts: 14
I am close to product cart testing just finishing up a few visual template tweaks then onto virtuemart stuff tonight, as i have not addressed the first issue yet, i would assume that it will still be apparent on my site, could you provide any clarification on how to implement your solution in my multi-template environment (eg the settings for metatemplate if anything is different for my setup) Im more than happy to do any testing and give feedback :-)

 Especially after all the help you've given!!!

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Hi Edzz,

the first problem (with POST requests in the shopping cart) should be able to be fixed with Chameleon and the tweak above, even (or especially) in multi-template environments.

If you're having trouble with that (i.e. you try it with MetaTemplate and it stuffs things up, then you turn off Chameleon and it comes back to normal again), then please let me know! I need some more feedback on that!

Cheers,
Stephen
Regards,
Stephen Brandon
MetaMod and MetaTemplate author