Skip to content

Commit

Permalink
Add "sub-layout" option
Browse files Browse the repository at this point in the history
Allow to use different layout for sub-pages of a menu item page.
  • Loading branch information
khanhlh committed Dec 29, 2014
1 parent b20fddb commit 860efd5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
21 changes: 20 additions & 1 deletion source/plg_system_t3/includes/core/template.php
Expand Up @@ -135,7 +135,26 @@ public function setParam($name, $value)
public function getLayout()
{
$input = JFactory::getApplication()->input;
return $input->getCmd('tmpl') ? $input->getCmd('tmpl') : $this->getParam('mainlayout', 'default');
// get override layout by tmpl
$layout = $input->getCmd('tmpl');
if ($layout && T3Path::getPath('tpls/' . $layout . '.php')) return $layout;
// detect if this is menu page or sub-page if set
$menu_page = true;
$input = JFactory::getApplication()->input;
$active = JFactory::getApplication()->getMenu()->getActive();
if ($active && isset($active->query)) {
foreach ($active->query as $name => $value) {
if ($input->get($name, null, 'raw') != $value) {
$menu_page = false;
break;
}
}
}

$mainlayout = $this->getParam('mainlayout', 'default');
$sublayout = $this->getParam('sublayout', '');

return !$menu_page && $sublayout ? $sublayout : $mainlayout;
}


Expand Down
3 changes: 2 additions & 1 deletion source/plg_system_t3/language/en-GB/en-GB.plg_system_t3.ini
Expand Up @@ -183,7 +183,8 @@ T3_LAYOUT_LABEL_DELETE = "Delete"
T3_LAYOUT_LABEL_PURGE = "Purge"
T3_LAYOUT_DESC_DELETE = "Remove cloned layout & setting"
T3_LAYOUT_DESC_PURGE = "Remove both cloned and default layout"

T3_LAYOUT_SUBLAYOUT_LABEL = "Sub Layout"
T3_LAYOUT_SUBLAYOUT_DES = "Layout for page which is not directly linked to a menu item. -Use Default- value to use the same above layout."

; NAVIGATION
T3_NAVIGATION_LABEL = "Navigation"
Expand Down
7 changes: 7 additions & 0 deletions source/plg_system_t3/t3.php
Expand Up @@ -242,6 +242,13 @@ function onContentPrepareForm($form, $data)
//extend extra fields
T3Bot::extraFields($form, $data, $tplpath);
}

// Extended by T3
$extended = T3_ADMIN_PATH . '/admin/form/' . $form->getName() . '.xml';
if (is_file($extended)) {
$form->loadFile($extended, false);
}

}
}

Expand Down

0 comments on commit 860efd5

Please sign in to comment.