[TYPO3] Unique wrap based on menuitem pid

Christopher Torgalson bedlamhotel at gmail.com
Mon Jul 9 22:47:44 CEST 2007


On 7/9/07, James Corell <jcorell at e-p-c-s.com> wrote:
> I'm beginning to think that TYPO3 doesn't have the capability to make
> exceptions for individual menuitems. This is a serious downside to TYPO3.

No, the downside is that it takes a while to figure out how to do it ;-)

> I've tried [if] [else] statements, which only work on global data, not the
> menuitem data.
> I've tried stdWrap.if statements, which work, but don't provide "else"
> capability.

I've just had a look through the thread; a big part of the problem is
that you are ignoring the 'data type' column in the property tables in
the TSref--for example, the tmenuitem property 'wrapItemAndSub' does
not have the data type 'stdWrap', so .if /cannot/ work. For more
information about what the stuff in the TSref is actually telling you,
have a look at this [1].

As for conditionals, there are five conditional methods in TS:

1. TS conditions--you've discovered these, but they're probably not
right for what you need,

2. .ifEmpty, another .stdWrap property but probably not what you need,

3. .ifBlank, see .ifEmpty

4. .if--this may be right for you. If you decide that you /must/ use
.if, simply create two different cObjects and use mutually exclusive
.if setups for each of them (this is not a very good solution,
especially if there are more than two options).

5. CASE cObject. This is probably what you need, as it allows you to
set up any number of ways of rendering (or not rendering) content on
the basis of some value [2], [3].

> Somebody please tell me I don't have to create a user-written handler
> (PHP/Javascript) of some kind to specify unique menuitem behavior for
> individual links?

You don't. CASE will do it for certain; use something like this to
completely re-write the link in the menu:

NO {
  stdWrap.cObject = CASE
  stdWrap.cObject {
     key.field = uid

     ### Default rendering:
     default = HTML
     default {
       value {
         field = title
         typolink {
           parameter.field = uid
           wrap <li>|</li>

     ### Rendering for page uid 357:
     357 = HTML
     357 {
       value {
         field = title
         typolink {
           parameter.field = uid
           wrap <li id="special_link">|</li>

There may be a tidier way--I only took a quick look through the
thread, but maybe this will get you started.

Christopher Torgalson

[1] http://www.typo3apprentice.com/howto/rtfm/
[2] http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/17/
[3] http://typo3.org/documentation/document-library/core-documentation/doc_core_tsbyex/0.0.16/view/5/1/#id2852461

More information about the TYPO3-english mailing list