是否有ATagAfterWrap而不是ATagBeforeWrap或wrapItemAndSub的wrapSubAndItem?

时间:2013-03-27 13:11:26

标签: typo3 typoscript

首先,当涉及到Typoscript时我总是新手,并且只是想对页面进行一些css调整。但是我想做一个小调整。而不是这个(在这种情况下使用提到的ATagBeforeWrap):

<menulvl1>
    <li>
       <a>Menu-Lvl 1 Link</a>
       <submenu>
          <!--.... -->
       </submenu>
    </li>
</menulvl1>

没有ATagBeforeWrap(或设置为0),我读到我会得到这个:

 <li>
    <a>
        <submenu>
          <!--.... -->
       </submenu>
    </a>

 </li>

但我想要的是:

<li>    
    <submenu></submenu>
    <a>Menu-Lvl 1Link</a>
</li>

修改 这是负责渲染的typoscript。很抱歉代码很多:

# Copy basic menu object from TS template 'menu' so we don't have to repeat all that

#lib.menu.level2.wrap = TEXT

menu.top < menu.defaults
menu.top {
  # Also show pages which have not-in-menu flag set in page properties
  includeNotInMenu = 0

  # Create a menu out of the pages specifically listed under special.value
  special = directory
  special.value = {$menu.top.pages}

  entryLevel = 0

  1 {
    expAll = 1
    wrap = <ul class="layer1">|</ul>
    NO {
      doNotShowLink = 0
      wrapItemAndSub = <li class="first">|</li>|*|<li>|</li>|*|<li class="last">|</li>
      ATagParams = class="layer1"
    }
    ACT{
        wrapItemAndSub = <li class="first selected">|</li>|*|<li class="selected">|</li>|*|<li class="last selected">|</li>
        ATagParams = class="layer1 active"
    }
    IFSUB < .NO
    IFSUB.ATagParams = class="layer1"
    CUR < .ACT
    CUR.ATagParams = class="layer1 selected"
    CURIFSUB < .ACT
    CURIFSUB.ATagParams = class="layer1 selected"
  }

  2 < .1

  2.wrap(
    <div class="layer2" style="display:none;">
        <div class="inner-wrapper">
  )
  #2.wrap.insertData = 1

  2.NO.doNotLinkIt = 1
  2.ACT.doNotLinkIt = 1
  2.IFSUB.doNotLinkIt = 1
  2.CUR.doNotLinkIt = 1
  2.CURIFSUB.doNotLinkIt = 1

  2.NO.wrapItemAndSub = <div class="layer2-col first">|</div>|*|<div class="layer2-col">|</div>|*|<div class="layer2-col last">|</div>
  2.NO.ATagParams = class="layer2"
  2.ACT.wrapItemAndSub = <div class="layer2-col first">|</div>|*|<div class="layer2-col">|</div>|*|<div class="layer2-col last">|</div>
  2.ACT.ATagParams = class="layer2 selected"
  2.IFSUB.wrapItemAndSub = <div class="layer2-col first">|</div>|*|<div class="layer2-col">|</div>|*|<div class="layer2-col last">|</div>
  2.IFSUB.ATagParams = class="layer2"
  2.CUR.wrapItemAndSub = <div class="layer2-col first">|</div>|*|<div class="layer2-col">|</div>|*|<div class="layer2-col last">|</div>
  2.CUR.ATagParams = class="layer2 selected"
  2.CURIFSUB.wrapItemAndSub = <div class="layer2-col first">|</div>|*|<div class="layer2-col">|</div>|*|<div class="layer2-col last">|</div>
  2.CURIFSUB.ATagParams = class="layer2 selected"
  2.NO.linkWrap = <span class="layer2-headline">|</span>
  3 < .1
  #3.NO.doNotLinkIt = 0
  3.wrap = <ul class="layer2-wrap">|</ul>
  3.NO.wrapItemAndSub = <li>|</li>
  3.NO.ATagParams =
  3.ACT.ATagParams = class="active"
  3.IFSUB.ATagParams =
  3.CUR.ATagParams = class="selected"
  3.CURIFSUB.ATagParams = class="selected"

  stdWrap.prepend.data = LLL:{$filepaths.l10n}:nav_top
}

和默认值:

menu.defaults = HMENU
menu.defaults {
   1 = TMENU
   1 {
     wrap = <ul>|</ul>

     # Always unfold all sub-levels of the menu
     expAll = 0

     # Remove the (old) default behaviour which adds onfocus="blurLink(this);" to all links
     noBlur = 1

     # Define the normal state (not active, not selected) of menu items
     # Using NO=1 to activate normal state is not necessary, but useful when copying
     NO = 1
     NO {
       # Use the page title field the title property on the A-tag, but only if the navigation title is set
       ATagTitle {
         field = title
         fieldRequired = nav_title
       }

       # Use the option-split feature to generate a different wrap for the last item on a level of the menu
       # The last item on each level gets class="last" added for CSS styling purposes.
       #
       # See the TSref documentation for details about option split and other features:
       # http://typo3.org/documentation/document-library/references/doc_core_tsref/current/
       #wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
       wrapItemAndSub = <li>|</li>

       # HTML-encode special characters according to the PHP-function htmlSpecialChars
       stdWrap.htmlSpecialChars = 1
     }

     IFSUB = 1
     IFSUB < .NO
     IFSUB {
       wrapItemAndSub = <li class="subpages">|</li>
       ATagBeforeWrap = 1
     }

     # Copy properties of normal to active state, and then add a CSS class for styling
     ACT = 1
     ACT < .NO
     ACT {
       ATagParams = class="active"
     }

     # Copy properties of normal to current state, and then add a CSS class for styling
     CUR = 1
     CUR < .NO
     CUR {
       ATagParams = class="selected"
       #wrapItemAndSub = <li class="selected">|</li>
     }

     CURIFSUB < .IFSUB
     CURIFSUB {
       ATagParams = class="selected"
     }
   }
   2 < .1
   3 < .2
   stdWrap.prepend =< lib.srHint
 }

这有可能吗?

1 个答案:

答案 0 :(得分:1)

我认为唯一的方法是使用before.cObject = HMENU并根据包装内的当前值创建第二个菜单。