5

Is it possible to get parameters for a specific template (not the active template necessarily)?

Any advice would be appreciated.

//edit The template WILL NOT be active, so I need to get the template's parameters without:

$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
$param = $template->params->get('paramName', defaultValue);
2

You can do it like this:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query  ->select('params')
        ->from('#__template_styles')
        ->where('`template` = ' . $db->q('beez3')) // Just replace 'beez3' with with the name of your template
        ->where('client_id = 0'); // client_id = 0 for SITE and client_id = 1 for ADMIN templates
$db->setQuery($query);
$params = json_decode($db->loadResult());
echo $params->wrapperSmall; // replace wrapperSmall with desired parameter key

Hope it helps.

3

To get the active template parameters, you can use the following:

Code by @GDP (source)

$template = JFactory::getApplication()->getTemplate(true);
$params   = $template->params;
$variable = $params->get('variable');

However I would not recommend getting parameters from non-active template. Instead I suggest you set default values, for example.

$variable = $params->get('colour', '#FFFFFF');
  • Like I said, the template will most probably not be active due to some plugin I have that changes the template assignment. – Anriëtte Myburgh Nov 11 '14 at 14:47
  • If you include more specifics about your situation in your question, the programmers might be able to offer the more detailed solution. I didn't get from your question that you would be assigning templates to pages and that's why it's not necessarily active. Edit: you probably mean to use the DEFAULT active template for the site, right? – Toni Marie Nov 11 '14 at 15:09

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.