2

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:

  • in TypoScript

    arrayOfTitles= # titles of the pages with uid 1,2,3 and 4

  • in FLUID page

    <f:for each="{arrayOfTitles}" as="foo">
    <h1> {foo} </h1>
    </f:for>
    

Is this possbile

1 Answer 1

5

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
}
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for the reply. I am new to Typo3 and Typoscript. I'm having difficulty in understanding the solution. Can I create a plugin directly in my template as you mentioned ? I actually did that but nothing seems to be rendered in the front end. Or is there a process to first initiate the plugin or something ?
I assumed, that you created custom extension. For simple usage in raw TS, use HMENU - check my edit
What if I do not want the titles wrapped but want them assigned to some variable. So that I can do some additional manipulations or reuse them in the front end ?
Also, can you suggest me any good reference to create custom extensions ? I'm using Typo3 6.0.4
Extension Builder in version 2.5.0+ is dedicated for creating extensions in TYPO3 ver 6.0+
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.