如果内部 UL 没有值,则不显示外部 div

发布于 2024-11-28 08:46:00 字数 1938 浏览 2 评论 0原文

我有一个 HTML 模板,我使用 automaketemplate 制作了一个typo3模板。在此 HTML 中,我设置了这样的 div。

 <div class="bigPostItWrap">1 
                <div class="postit">2
                    <div class="postit_tesa">3</div>
                    <div class="postItWrap">4
                        <ul class="menusmall">5
                            <li>* Team</li>6
                            <li>* something else</li>
                            <li>* Third point</li>
                        </ul>
                    </div>
                </div>
    </div>

UL 应包含辅助导航,仅在选择某个主导航对象时才显示。由于它位于屏幕上的其他位置,我将其设置为一个像这样的独立菜单。

postitMenu = HMENU
postitMenu {
  # show the submenue relative to this entry level (?)
  entryLevel = 1
  # the first level of the menu is a text menu
  1 = TMENU
  # wrap the whole menu with <ul class="menu"> | </ul>
  1.wrap = <ul class="menusmall"> | </ul>

  # enable the "no"rmal state
  1.NO = 1
  # for the normal state, wrap it in li
  1.NO.linkWrap = <li>* |</li>

  #enable active state
  1.ACT = 1
  #copy all properties from normal state to active state
  1.ACT < .NO
  # disable the link for the active menu-point
  1.ACT.doNotLinkIt = 1
  # wrap the active menulink in li with the class = "active"
  1.ACT.allWrap = <li class="active">* |</li>
}

所有这些都运行良好,并且菜单仅显示在正确的主菜单条目上。但是外部 div postit 包含一个背景图像(您可能会猜到,它是一个 postIt),并且 postit_tesa 在 postit 顶部显示一条胶带。当然,如果我不显示二级菜单,我也不希望渲染 postIt 和胶带。

由于我对typoScript相当陌生,所以我不知道如何实现这一点。我不知道如何谷歌,至少我没有找到任何解决方案。我认为不知何故,如果我围绕它制作 bigPostItWrap ,我可能会做类似

if there is an li-element, 
render the subpart bigPostItWrap, 
else, don't render it

但我无法落后于 ts-if 的事情,或者做一些完全错误的事情..任何提示都会受到赞赏。对于专业人士来说,这可能很容易,但我无法弄清楚,我从前天开始就在尝试 -.-

谢谢!

I have a HTML template which I made a typo3 template of, using automaketemplate. In this HTML, I have a setup of divs like this

 <div class="bigPostItWrap">1 
                <div class="postit">2
                    <div class="postit_tesa">3</div>
                    <div class="postItWrap">4
                        <ul class="menusmall">5
                            <li>* Team</li>6
                            <li>* something else</li>
                            <li>* Third point</li>
                        </ul>
                    </div>
                </div>
    </div>

The UL should contain the secondary navigation, only displayed if a certain primary navigation object is selected. As it is positioned somewhere else on the screen, I made it an independent menu like this

postitMenu = HMENU
postitMenu {
  # show the submenue relative to this entry level (?)
  entryLevel = 1
  # the first level of the menu is a text menu
  1 = TMENU
  # wrap the whole menu with <ul class="menu"> | </ul>
  1.wrap = <ul class="menusmall"> | </ul>

  # enable the "no"rmal state
  1.NO = 1
  # for the normal state, wrap it in li
  1.NO.linkWrap = <li>* |</li>

  #enable active state
  1.ACT = 1
  #copy all properties from normal state to active state
  1.ACT < .NO
  # disable the link for the active menu-point
  1.ACT.doNotLinkIt = 1
  # wrap the active menulink in li with the class = "active"
  1.ACT.allWrap = <li class="active">* |</li>
}

All this works quite well, and the menu only gets displayed on the correct main-menu entry. But the outer div postit contains a background image (you may guess, it's a postIt), and the postit_tesa shows a strip of sticky tape on top of the postit. Of course, if I don't show the secondary menue, i also don't want the postIt and sticky tape to be rendered.

As I am fairly new to typoScript, I have no clue how to achieve that. And I don't know how to google for that, at least I don't find any solution. I thought that somehow, if I make the bigPostItWrap around it, I may do something like

if there is an li-element, 
render the subpart bigPostItWrap, 
else, don't render it

but II can't get behind the ts-if, or doing something totaly wrong.. Any hint is appreciated. It's probably ridiculous easy for a pro, but I can't figure it out, and I'm trying since the day before yesterday -.-

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ペ泪落弦音 2024-12-05 08:46:00

对于面临同样问题的人:我用作弊的方法做到了..事实上有两种方法。

首先,我简单地制作了外部的wrapp-div,并为其分配了所有其他代码,然后在该代码内构建了菜单(如果页面ID 是我想要的)。这确实有效,但效果并不好。

第二种可能更干净的方法是通过 css。只需将包装器的可见性设置为隐藏即可。比 maketypo3 为你的 body 标签提供 body 标签内的 UID

# generate a bodyTag with the current page UID
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = uid
page.bodyTagCObject.wrap = <body id="pid-|">

在你的 css 中,创建一个新的选择器(假设第 3 页是你想要菜单出现的那个)

#pid-3 .your-wrappers-name {
visibility: visible;
}

就这样。 Div 仅在 UID 为 3 的页面上可见。

For anyone facing the same problem: I did it with a cheat.. in fact there are two ways.

First, I simply made the outer wrap-div, and assigned it all the other code, and than made the menu build inside this code, if the page ID was the one i wanted. That worked, but wasn't nice.

The second, probably cleaner approach is via css.. Just set the wrapper's visibility to hidden. Than make typo3 give your body tag the UID inside the body tag

# generate a bodyTag with the current page UID
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = uid
page.bodyTagCObject.wrap = <body id="pid-|">

In your css, make a new selector (assuming page 3 is the one you want the menu to appear)

#pid-3 .your-wrappers-name {
visibility: visible;
}

There you go. The Div will only be visible on the page with the UID 3.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文