Skip to content

Commit

Permalink
Ticket #4641 - Use HTMX to load page content without genaral page str…
Browse files Browse the repository at this point in the history
…ucture.
  • Loading branch information
AntonLV committed Jul 11, 2024
1 parent bd59269 commit 6f452fc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
10 changes: 10 additions & 0 deletions inc/classes/BxDolMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ static public function processMenuTrigger ($sMenuTriggerName)
return true;
}

public function isHtmx()
{
return $this->_bHx;
}

/**
* Check if the menu is visible. The menu is visible if at least one menu item is visible.
* @return boolean
Expand Down Expand Up @@ -320,6 +325,11 @@ public function setDynamicMode ($bDynamicMode)
$this->_bDynamicMode = $bDynamicMode;
}

public function setHtmx($bHx)
{
$this->_bHx = $bHx;
}

/**
* Get an arrey of replacable markers.
* @return an array with markers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
*/
class BxTemplMenuSidebarSite extends BxTemplMenu
{
protected $_sPageUri;
protected $_aHideFromMenu;

public function __construct ($aObject, $oTemplate = false)
{
parent::__construct ($aObject, $oTemplate);


list($sPageUrl, $aPageParams) = bx_get_base_url_inline();
$this->_sPageUri = !empty($aPageParams['i']) ? $aPageParams['i'] : '';

$this->_aHideFromMenu = ['search', 'more-auto'];
}

Expand All @@ -30,7 +34,7 @@ protected function _getMenuItem ($a)
if(empty($aResult) || !is_array($aResult))
return $aResult;

$aTmplVarsSubmenu = array();
$aTmplVarsSubmenu = [];
$bTmplVarsSubmenu = !empty($aResult['submenu_object']);
if($bTmplVarsSubmenu) {
$aResult['bx_if:onclick'] = [
Expand All @@ -40,24 +44,29 @@ protected function _getMenuItem ($a)
]];
$aResult['class_add'] .= ' bx-si-dropdown-has';

if(($oSubmenu = BxDolMenu::getObjectInstance($aResult['submenu_object'])) !== false)
if(($oSubmenu = BxDolMenu::getObjectInstance($aResult['submenu_object'])) !== false) {
$aSubmenuItems = $oSubmenu->getMenuItemsRaw();
if($oSubmenu->isHtmx() && !$this->_isSelected($a) && !array_key_exists($this->_sPageUri, $aSubmenuItems))
$oSubmenu->setHtmx(false);

$aTmplVarsSubmenu['bx_repeat:submenu_items'] = $oSubmenu->getMenuItems();
}
}

$aResult['bx_if:show_arrow'] = array (
$aResult['bx_if:show_arrow'] = [
'condition' => false && $bTmplVarsSubmenu,
'content' => array(),
);
'content' => [true],
];

$aResult['bx_if:show_line'] = array (
$aResult['bx_if:show_line'] = [
'condition' => true,
'content' => array(),
);
'content' => [true],
];

$aResult['bx_if:show_submenu'] = array (
$aResult['bx_if:show_submenu'] = [
'condition' => $bTmplVarsSubmenu,
'content' => $aTmplVarsSubmenu,
);
];

return $aResult;
}
Expand Down
4 changes: 4 additions & 0 deletions modules/boonex/artificer/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,8 @@ BxArtificerUtils.prototype.submenuClickAl = function(oElement) {
oItem.parents('li:first').siblings().removeClass(sClass);
if(oItem.parents('.bx-popup-applied.bx-popup-menu'))
$('.bx-popup-applied:visible').dolPopupHide();

var sSidebar = 'site';
if(bx_sidebar_active(sSidebar))
bx_sidebar_toggle(sSidebar);
};

0 comments on commit 6f452fc

Please sign in to comment.