0

I want to print the fields title, nav_title and subtitle with Typoscript. I saw that there are several possibilities. E.g. data, field, levelfield, leveltitle, ...

Currently I'm using this code (because the only one which works for me so far):

lib.heading = TEXT
lib.heading.dataWrap = <p class="title"> {leveltitle:0} </p>

but I want something with alternatives like this

stdWrap.field = subtitle // nav_title // title

What is the correct way of retrieving these fields?

Edit:

[userFunc = user_isMobile]

page.headerData.10 = TEXT
page.headerData.10.value (
    // ...
)

// ...

lib.heading = TEXT
#lib.heading.dataWrap = <p class="title"> {leveltitle:0} </p>

lib.heading {
  field = title 
  wrap = <p class="title"> | </p>
}

lib.subpages = HMENU
lib.subpages {
  // ...
}

[global]

The userfunction itself is a function in a php script (user_mobile.php). It makes a user agent detection for mobile devices and returns true or false.

testing
  • 19,681
  • 50
  • 236
  • 417

1 Answers1

0

field will get values from the current data which in your context is the data of the current page.

lib.heading = TEXT
lib.heading {
  field = subtitle // nav_title // title
  wrap = <p class="title">|</p>
}

leveltitle, leveluid, levelmedia, etc. allow you to retrieve some of the data from other pages in the rootline of the current page.

For more information see getText in the documentation.

tmt
  • 7,611
  • 4
  • 32
  • 46
  • When I use this code the output is empty `

    `.
    – testing Nov 20 '12 at 16:04
  • Try `field = subtitle // title`, that is only 2 fields. Does it make any difference? – tmt Nov 20 '12 at 17:15
  • No it doesn't make any difference. This code only worked for me when building a menu. – testing Nov 21 '12 at 09:48
  • 1. Check that this code is not inside some other code. 2. Make sure you are not leaving out `|` from `

    |

    `.
    – tmt Nov 21 '12 at 13:19
  • It's in a `userFunc` condition, but the condition is fulfilled because with `{leveltitle:0}` I get the results. Also the pipe is in the wrap: `lib.heading = TEXT lib.heading { field = title wrap =

    |

    }`
    – testing Nov 21 '12 at 15:58
  • Can you explain that "it's in a userFuns"? The thing is, `leveltitle` and similar are sort of special and are usable in any context. On the other hand for `field` the data change according to the context. If you can, post bigger chunk of TypoScript code to see where you are trying to use this. – tmt Nov 21 '12 at 16:42
  • I edited my question, but not really much more information here. Tell me if you need something. – testing Nov 21 '12 at 16:49
  • I don't think the condition can have any effect on this whatsoever but just to be sure, have you tried taking the code out of the condition? – tmt Nov 21 '12 at 16:53
  • Now I tried it without the condition - still the same result. – testing Nov 22 '12 at 14:26
  • The last thing that comes to my mind is to use *Template -> Template Analyzer* to check for any possible problem with the code. – tmt Nov 22 '12 at 15:57
  • I now used `{page:sub_title}` and it is giving me the information I wanted. But it is not ideal because I often have two times the same headline (this is a design mistake). Though your code still not work and template analyzer didn't show me an error. – testing Dec 01 '12 at 14:38