HMENU仅在自定义字段中具有特定值的页面

时间:2013-12-02 13:29:03

标签: typo3 typoscript

我在表格页面中有一个自定义字段(比如说名为myfield),其值为0,1或2.我现在想要为具有特定值的所有页面创建一个HMENU(例如,所有带有myfield的页面) = 1)在这个领域。

我怎么能得到这个?

据我所知,我无法在HMENU中添加where子句。那么我需要一个USER_INT吗?

它会以某种方式工作:

includeLibs.something = mypath/user_myclass.php
lib.servicenav = HMENU
lib.servicenav {
  special = list
  special.value = USER
  special.value.userFunc = user_myclass->myFunction
  special.value.myfieldvalue = 1 # 0, 1, or 3
}

user_myclass.php-> myFunction的:

function myFunction($a, $myfieldvalue) {
  // - search all pages with $myfieldvalue
  // - add all pids of this page to the returnvalue (as string)
  $returnvalue = "5, 19, 200";
  return $returnvalue;
}

此解决方案有效吗?有更好的解决方案吗?

编辑:cascavals解决方案:

它适用于一个小型测试项目:

lib.menu = HMENU
lib.menu{
special = list
special.value.cObject = CONTENT
  special.value.cObject {
    table = pages
    select {
      where = myfield=0
    }
    renderObj = TEXT
    renderObj {
      field = uid
      wrap = |,
    }
  }
entrylevel = 1
1 = TMENU
1.NO = 1
1.NO.linkWrap =
<div class="menu">|</div>
überschreibt
2 < .1
2.NO.linkWrap =
<div class="menu-ebene2">|</div>

但它在一个更大的项目中不起作用(我没有输出): 此外,当我从上面复制菜单时,它在此项目中不起作用..

lib.navigation = HMENU
lib.navigation {
special = list
special.value.cObject = CONTENT
  special.value.cObject {
    table = pages
    select {
      where = myfield=0
    }
    renderObj = TEXT
    renderObj {
      field = uid
      wrap = |,
    }
  }
    1 = TMENU
    1 {
        noBlur = 1
        expAll = 0
        wrap = <ul class="nav1">|</ul>
        NO = 1
        NO {
            wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
            altText = subtitle // title
            title = subtitle // title
        }

        CUR < .NO
        CUR.ATagParams = class="active"
        CUR.wrapItemAndSub = <li class="current first">|</li> |*| <li class="current">|</li> |*| <li class="current last">|</li>

        ACT < .CUR
        ACT = 1
        ACT.ATagParams = class="active"


    }
    2 = TMENU
    2 < .1
    2 {
        expAll = 0
        wrap = <ul class="nav2">|</ul>
    }

}

1 个答案:

答案 0 :(得分:2)

由于special.valuestdWrap,您仍然可以动态选择页面UID并创建一个逗号分隔的列表:

lib.servicenav = HMENU
lib.servicenav {
  special = list
  special.value.cObject = CONTENT
  special.value.cObject {
    table = pages
    select {
      pidInList = [UID of the root page of your website]
      recursive = 99
      where = myfield=1
    }
    renderObj = TEXT
    renderObj {
      field = uid
      wrap = |,
    }
  }
}