Skip to content

Commit ea2bc15

Browse files
committed
Additional Classes on body level.
As listed here: https://www.joomdev.com/forum/astroid-framework/3336-retrieve-item-id-from-the-menu#15730 1. Corrected spelling for Itemid, I is uppercase. 2. Add menu item alias in the class, this is what you add as the menu class suffix anyway. 3. Adding template style ID, in case you are running multiple styles of Astroid and want styling for each one of them. These corrections would not have been possible without idea's received from Jonathan Magoga (@jonrz) and Serge Billon (web54.fr).
1 parent efc379d commit ea2bc15

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

astroid/astroid-framework/framework/template.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,14 @@ public function loadTemplateJS($components = '') {
644644
$this->setLog("Javascripts Loaded!", "success");
645645
}
646646

647+
/*
648+
* Function to return classes imploded in the body tag on the website.
649+
*/
647650
public function bodyClass($body_class, $language = '', $direction = '') {
651+
$template = JFactory::getApplication()->getTemplate(true);
648652
$class = [];
649653
$app = JFactory::getApplication();
650654
$menu = $app->getMenu()->getActive();
651-
652655
$class[] = "site";
653656
$class[] = "astroid-framework";
654657

@@ -658,7 +661,7 @@ public function bodyClass($body_class, $language = '', $direction = '') {
658661
$task = $app->input->get('task', '', 'STRING');
659662
$header = $this->params->get('header', TRUE);
660663
$headerMode = $this->params->get('header_mode', 'horizontal', 'STRING');
661-
$itemid = $app->input->get('itemid', '', 'INT');
664+
$Itemid = $app->input->get('Itemid', '', 'INT');
662665

663666
if (!empty($option)) {
664667
$class[] = htmlspecialchars(str_replace('_', '-', $option));
@@ -672,8 +675,8 @@ public function bodyClass($body_class, $language = '', $direction = '') {
672675
if (!empty($task)) {
673676
$class[] = 'task-' . $task;
674677
}
675-
if (!empty($itemid)) {
676-
$class[] = 'itemid-' . $itemid;
678+
if (!empty($Itemid)) {
679+
$class[] = 'itemid-' . $Itemid;
677680
}
678681

679682
if ($header && !empty($headerMode) && $headerMode == 'sidebar') {
@@ -682,11 +685,16 @@ public function bodyClass($body_class, $language = '', $direction = '') {
682685
}
683686

684687
if (isset($menu) && $menu) {
685-
if ($menu->params->get('pageclass_sfx')) {
688+
if ($menu->get('pageclass_sfx')) {
686689
$class[] = $menu->params->get('pageclass_sfx');
690+
}
691+
if ($menu->get('alias')) {
692+
$class[] = $menu->get('alias');
687693
}
688694
}
689-
695+
if (!empty($template->id)) {
696+
$class[] = 'tp-style-' . $template->id;
697+
}
690698
if (!empty($language)) {
691699
$class[] = $language;
692700
}

0 commit comments

Comments
 (0)