排版:如果选择了某些 backend_layout,则不显示子菜单 [英] typoscript: do not show submenu if certain backend_layout is selected

查看:28
本文介绍了排版:如果选择了某些 backend_layout,则不显示子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个带有图标的特殊平移子菜单,可以选择一个名为 pagets__panmenu 的特定 backend_layout 插入图标,如果选择了该布局,则主菜单不应显示子菜单并链接到页面打开子...

I made a special panning sub menu with icons which can be inserted choosing a specific backend_layout named pagets__panmenu , if that layout is selected the main menu should not display a sub menu and link to the page instead of opening a sub ...

我使用typo3 V7.6.11 和流畅的样式内容

I work with typo3 V7.6.11 and fluid styled content

读取值的部分工作正常:

The part reading the value works correctly:

NO = 1
NO {
  before.cObject = LOAD_REGISTER
  before.cObject{
    panmenu.cObject = TEXT
    panmenu.cObject.data.dataWrap = DB:pages:{field:uid}:backend_layout
  }
  ATagBeforeWrap = 1
  wrapItemAndSub = <li>|</li>
  stdWrap.htmlSpecialChars = 1
}

这是我最大的努力来匹配,但它不起作用:

This is my best effort to match, but its not working:

IFSUB <.NO
IFSUB {
    wrapItemAndSub = <li class="dropdown">|</li>
    wrapItemAndSub.override = <li>|</li>        
    wrapItemAndSub.override.if {
        value.data = register:panmenu
        equals = pagets__panmenu
    }

    ATagParams = class="dropdown-toggle" data-toggle="dropdown" 
    ATagBeforeWrap = 1
}

我知道还有 2 <.1 必须被抑制,我试图让 if 工作以保持初学者的风格和链接干净......

I know that also the 2 < .1 has to be suppressed, I'm trying to get the if to work to keep the style and link clean for starters ...

推荐答案

首先:你有没有设置TMENU.IFSUB = 1?否则,您在 IFSUB 中所做的一切都将无效.

First of all: have you set TMENU.IFSUB = 1? Else, everything you do in IFSUB won't have an effect.

现在有一些一般性的想法:

Now some general thoughts:

a) 通常,后端布局用于切换整个页面模板:

a) Normally, backend layouts are used to switch an entire page template:

page.10 = FLUIDTEMPLATE
page.10 {
  file.stdWrap.cObject = CASE
  file.stdWrap.cObject {
    key.data = pagelayout

    default = TEXT
    default.value = {$myTemplatePath}/Standard.html

    1 = TEXT
    1.value = {$myTemplatePath}/Home.html

    2 = TEXT
    2.value = {$myTemplatePath}/Landing.html

  }
  layoutRootPath = {$myLayoutPath}
  partialRootPath = {$myPartialPath}
}

因此这会启动整个页面的前端渲染,其中带有 uid 1 的 backend_layout 将使用 Home.html 模板,带有 uid 2 的 backend_layout 将使用 Landing.html 模板,所有其他(=默认)将使用 Standard.html 模板.

So this initiates the frontend rendering for the entire page, where backend_layout with uid 1 will use the Home.html template, backend_layout with uid 2 will use the Landing.html template, and all others (=default) will use the Standard.html template.

如果您通过这种方法构建您的网站,我建议您这样做

If you build your site by this method, I would recommend doing

# that's the original version of your menu
lib.panmenu = HMENU
lib.panmenu {
 // ...
}

# make a copy of the original 
lib.panmenu_variant < lib.panmenu
# modify it as required 
lib.panmenu_variant.1.NO {   
  // ... 
}

现在,在您的页面模板(您通过上面的 CASE 单独调用)中,您可以使用

Now, in your page Templates (which you call separately via the CASE from above), you can either use

<f:cObject typoscriptObjectPath="lib.panmenu" />

<f:cObject typoscriptObjectPath="lib.panmenu_variant" />

b) 但是如果您不想遵循这种方法,您也应该能够在任何 cObject 上使用 backend_layout CASE.CASE 变体已经证明对我来说更加健壮.

b) But if you don't want to follow that approach, you should also be able to use the backend_layout CASE on any cObject. The CASE variant has proven much more robust for me.

这里是我如何尝试让 CASE 工作(未经测试!)

Here' how I'd try to get the CASE working (untested!)

// suppose temp.navigation_main is your full menu
temp.navigation_main_variant < temp.navigation_main 
temp.navigation_main_variant {
    // modify the menu as you please
    10.2 >
    10.1.IFSUB.wrapItemAndSub = <li>|</li>
}

// use lib.nav in your page
lib.nav = CASE
lib.nav {
    key.data = pagelayout
    // normally, lib.nav is the full navigation
    default < lib.navigation_main
    // except if be layout 1 is selected
    1 < lib.navigation_main_variant
  }
}

c) 几年前我用 LOAD_REGISTERif 尝试过 TypoScript 结构,它们总是让我发疯.我不会在它们上投入太多精力,因为它们似乎是遗留参数,而不是 TYPO3 逻辑的未来开发方式.

c) I've tried TypoScript constructions with LOAD_REGISTER and ifs years ago and they always made me go crazy. I wouldn't invest too much energy into them, as they rather seem to be legacy parameters than the future way of development for TYPO3 logic.

这篇关于排版:如果选择了某些 backend_layout,则不显示子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆