在我的扩展中,有类别和产品。我希望类别显示为子菜单。
我的页面树如下所示:
在“衣服”(uid: 2)和“工作服”(uid: 4)页上,我有一个插件,可以显示类别和产品。
要显示的类别在TS安装程序中定义(每个页面上都有一个ext+模板),如下所示:
plugin.tx_productsdb.settings.categories = 1,2,3,4我的子导航的字体如下所示:
nav.subnavigation = COA
nav.subnavigation {
10 = HMENU
10 {
entryLevel = 0
1 = TMENU
1 {
wrap = <ul>|</ul>
NO = 0
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ACT = 1
ACT.wrapItemAndSub = <li class="active first">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
ACT.ATagParams = class="active"
CUR < .ACT
}
2 < .1
2.wrap = <ul class="level2">|</ul>
3 < .1
3.wrap = <ul class="level3">|</ul>
}
}我已经尝试过使用HMENU的itemArrayProcFunc属性,但是我找不到如何使用名称空间扩展的示例。
我试过这个:
10 = HMENU
10 {
entryLevel = 0
itemArrayProcFunc = Vendor\Extension\Hooks\Subnavigation->process这是一个功能:
class Subnavigation
{
/**
* @param $menuArr
* @param $conf
*/
public function process(&$menuArr, &$conf)
{
// show me, that something is happening here ... pretty please!
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($menuArr);
exit;
}
}如果你有做这件事的例子,请告诉我。提前谢谢。
发布于 2017-02-21 20:43:23
我有一个产品和类别的项目。类别应该显示在菜单中,我通过调用AJAX方法的JavaScript来解决这个问题。AJAX方法调用预定义的页面类型,例如index.php?id=xx&type=xx
TypoScript看起来如下所示:
menuItems = PAGE
menuItems.typeNum = xx
menuItems {
config {
disableAllHeaderCode = 1
no_cache = 1
}
10 = USER_INT
10.userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
10 {
extensionName = ExtensionName
pluginName = Plugin
vendorName = Vendor
controller = Product
action = getMenu
switchableControllerActions {
Product {
1 = getMenu
}
}
view < plugin.tx_plugin.view
persistence < plugin.tx_plugin.persistence
settings < plugin.tx_plugin.settings
}
}控制器操作如下所示:
/**
* @return void
*/
public function getMenuAction()
{
$menuItems = [];
$categories = $this->categoryRepository->findAll();
foreach ($categories as $category) {
/** @var Category $category */
$menuItems[] = [
'name' => $category->getTitle(),
'link' => $this->getLinkForCategory($category),
'id' => $category->getUid()
];
}
$this->view->assign('menuItems', $menuItems);
echo $this->view->render();
exit;
}在流体中,您只需创建
发布于 2017-02-23 15:15:48
最后,在多次尝试失败之后,我放弃了使用itemArrayProcFunc.的方法。
我的解决方案与Thomas发布的方案有些相似之处。
我正在使用TS条件,并完全由我自己构建导航。
[PIDinRootline = 2] || [PIDinRootline = 3]
lib.subnav >
lib.subnav = USER_INT
lib.subnav {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
vendorName = Vendor
extensionName = ExtensionName
pluginName = pluginName
controller = Controller
action = getSubnavigation
view < plugin.tx_plugin.view
persistence < plugin.tx_plugin.persistence
settings < plugin.tx_plugin.settings
}
[global]我的主计长的行动:
public function getSubnavigationAction()
{
$rootline = $this->pageRepository->getRootLine($GLOBALS['TSFE']->id);
// assumption: main page is always on level 1
$rootId = $rootline[1]['uid'];
$treePids = $this->getTreePids($rootId);
$pages = $this->pageRepository->getMenuForPages($treePids, 'uid, pid, title', 'sorting', ' AND hidden=0 AND deleted=0');
$rootPage = $pages[$rootId];
$tree = $this->buildTree($rootPage, $pages);
$menu = $this->buildMenu($tree);
$current = $this->argumentService->getArgument('tx_productsdb_categories', 'category');
$parent = 0;
if($this->argumentService->hasArgument('tx_productsdb_categories', 'parent')) {
$parent = $this->argumentService->getArgument('tx_productsdb_categories', 'parent');
}
$this->view->assign('parent', $parent);
$this->view->assign('current', $current);
$this->view->assign('menu', $menu);
$this->view->assign('settings', $this->settings);
}然后菜单是在流体中构建的。
https://stackoverflow.com/questions/42329517
复制相似问题