Skip to content

Instantly share code, notes, and snippets.

@phproberto
Last active February 15, 2018 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phproberto/d5900820af9db4bd092bcf527e1b50eb to your computer and use it in GitHub Desktop.
Save phproberto/d5900820af9db4bd092bcf527e1b50eb to your computer and use it in GitHub Desktop.
Joomla: Use custom field for layout in category view
<?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
if (property_exists($this->category, 'jcfields'))
{
$fields = $this->category->jcfields;
}
else
{
$fields = FieldsHelper::getFields('com_content.categories', $this->category);
}
$layout = 'default';
foreach ($fields as $field)
{
if ($field->name === 'custom-category-layout')
{
$customLayout = trim($field->rawvalue);
if (!empty($customLayout))
{
$layout = $customLayout;
}
break;
}
}
echo '<pre>'; print_r($layout); echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment