Last active
February 15, 2018 10:56
-
-
Save phproberto/d5900820af9db4bd092bcf527e1b50eb to your computer and use it in GitHub Desktop.
Joomla: Use custom field for layout in category view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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