1
votes

I am trying to get the second level of my HMENU to be different depending on what the parent id is.

Specifically, I need to add a COA to the TMENU when the pid is a specific number.

I figured I should be able to do this somehow using a CASE, but I haven't found the right setup to get it working right.

This is my incorrect code that shows what I want to do:

lib.mymenu = HMENU
lib.mymenu { 
  1 = TMENU
  1 {
    ...
  }
  2 = CASE
  2 {
    key.field = pid
    default = TMENU
    default {
      stdWrap.wrap = <ul>|</ul>
      expAll = 1
      NO = 1
      NO.wrapItemAndSub = <li>|</li>
    }
    23 = TMENU
    23 {
      stdWrap.wrap = <ul>|</ul>
      expAll = 1
      NO = 1
      NO.stdWrap.cObject = COA
      NO.stdWrap.cObject {
        ...
      }
    }
  }
}
1

1 Answers

2
votes

I doubt that you have the pid available at that level.
As the main part is identical I would differ only at the stdWrap with a simple if-wrap:

2 = TMENU
2 {
  stdWrap.wrap = <ul>|</ul>
  expAll = 1
  NO = 1
  NO {
      wrapItemAndSub = <li>|</li>
      /// what wrap do you want to use???
      stdWrap.wrap {
          cObject = COA
          cObject {
              :
          }
          if.equals.field = pid
          if.value = 23
      }
} 

in your code you also use cObject on stdWrap which does not match as stdWrap is no active wrap, but a container for a set of (wrap)functions.