dora
dora

Reputation: 1344

Typoscript Arrays and using them in FLUID

Assuming I have a project with the following web pages (Please see the screen shot)

enter image description here

The uids of Red, Blue, Post and Blog Page are 1,2,3 and 4 respectively.

Now, I would want to define an array or some kind of list in Typoscript which will contain the titles of all the root webpages. And this array, I can use it in my FLUID template and display all the titles.

Example:

Is this possbile

Upvotes: 2

Views: 6363

Answers (1)

biesior
biesior

Reputation: 55798

TypoScript from nature is an array, so easiest way to do what you want is just add some collection like this in your template:

plugin.tx_yourext {
  settings {
    domains {
      10 = one
      20 = two
      30 = three
      40 = four
    }
  }
}

so you can use it directly in the view

<f:for each="{settings.domains}" as="title">
    <h1>{title}</h1>
</f:for>

On the other hand, maybe it will be better to perform simple DB query to get these pages from database and then create simple array and assign it to the view as a param. In such case you will not need to change your TS in case of title change.

SQL pseudocode:

SELECT title FROM pages WHERE is_siteroot = 1 AND deleted = 0 AND hidden = 0 ORDER BY sorting ASC

Edit:

You can also do it with common HMENU in TypoScript (avoiding usage of views) just create menu object with special=list (of course instead 35, 56 you should give there uids of your root pages).

Finally wrap each item with <h1>|</h1> and add option: doNotLinkIt=1, most probably this snippet will work (written from top of my head, so you need to check it):

lib.myTitles = HMENU
lib.myTitles {
  special = list
  special.value = 1,2,3,4

  1 = TMENU
  1.NO.wrapItemAndSub = <h1>|</h1>
  1.NO.ATagTitle.field =  title
  1.NO.doNotLinkIt = 1
}

Upvotes: 5

Related Questions