2

I'm creating a Joomla! 3.x website with 3 different styles according to the visitor type (mostly color differences and different modules being displayed or not):

  • Blue style for "people"
  • Green style for small stores
  • Red style for big stores

The website also has 2 languages but the style is not going to change according to them.

My question is: What would be the best practice to manage those styles?

My ideas so far:

  • Use 3 different templates, however the only difference among them would be the css.
  • Use a single template with all styles on it and create (or find?) a plugin to take care (in session) of a class in according to the visitor's choice.
  • What template and framework are you using? – jonboy Aug 13 '14 at 16:33
  • Custom template, no framework (like Gantry, T3, and so on). – Shaz Aug 13 '14 at 16:49
1

I guess people, small and big stores will be different usergroups. So a simple and straight-forward approach, is to base your styles' variations on the usergroups and the ACL.

1. To display different modules: You can create Access Levels for each usergroup and assign the desired module on the associated access level of each usergroup.

2. To have different styles / Color scheme (CSS): You can create 3 extra css files, that will handle all style variations and the color schemes. Then in your template you can check for the usergroup of the current user, and call the relative css file.

How to access the user data

$user = JFactory::getUser(); //Get the current user object
$user->groups; //Returns an array with the ids of the usergroups of the user.



Alternative and a bit trickier approach to assign the styles:
You can backend CSS/Scheme/Style settings in your template and create 3 different styles from the backend, that will trigger the corresponding css rules or files for the template. Then you can create different menu items and give them access for each usergroup, and assign the corresponding template style to these menu items.

2

We've battled this in the past, and in our experience always gets messy, so abandoned it for a simpler approach. Afterwards, we found an extension called Chameleon, which was going to do exactly what we wanted, and what you're asking, but it was too late to implement in our project. I can't comment based on personal experience, but it seems highly rated in it's reviews, and appears to be quite powerful and flexible.

Chameleon detects:

★ Browser (IE v6, FF, iPhone, iPad, tablet, mobile etc; using Categorizr for smart detection)
★ Browser language
★ Date, time, time of day
★ Page type (article, category, front page etc)
★ Virtuemart page types, cart contents, categories & coupons
★ Hikashop page types, categories and specific items
★ K2 page types, categories, authors and more
★ User id and group, logged-in and logged-out users
★ Article id, section, category and tags (J3.x)
★ Component
★ Domain/sub-domain of your site
★ Page URL and HTTP referrer
★ Random probability
★ GeoIP detection of the guest’s city/country
★ All "children" of a given menu or menu item
★ Anything else you can detect with a snippet of PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.