I'm currently working on my first typo project and need to create a mega menu with an individual set of pages.
Many attempts failed or are not suitable for me. My current shot aims to group pages of the redirect type in a hidden page. In Typoscript I want to set the ID of the parent page containing these redirections and read the shortcut IDs of the children accordingly.
pageIds = CONTENT
pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
}
The next step would be to use the retrieved shortcut IDs in my HMENU of the type 'list'.
1 = HMENU
1 {
special = list
special {
value = # Assign retrieved IDs here
}
[...]
}
Typoscript is very confusing at first sight, so I would be glad to receive some hints how I can transfer the query's result, as a comma-seperated list, to the HMENU.
Thanks in advance!
Greetz.
First, you need to get a comma-separated list of the page UIDs you want to link. This can be achieved with a renderObj:
lib.pageIds = CONTENT
lib.pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
renderObj = TEXT
renderObj.stdWrap.field = shortcut
renderObj.stdWrap.wrap = |,
}
This should give you a comma-separated list of all records. Now you must apply these to the HMENU. As you can read in the documentation, the value property is stdWrap enabled, this means that you can copy a value when you use a cObject:
1 = HMENU
1 {
special = list
special {
value.cObject < lib.pageIds
}
[...]
}
I didn't test this, so maybe the configuration is not entirely complete.
Related
I want to use the first image out of a new entry to include in the page header.
Therefore i need the news fal_media data in TypoScript to pass it to my page fluid template.
I managed to get the first image as a file path by this TypoScript code:
lib.newsimage = FILES
lib.newsimage {
references {
table = tx_news_domain_model_news
uid.data = GP:tx_news_pi1|news
fieldName = fal_media
}
maxItems = 1
renderObj = IMG_RESOURCE
renderObj.file {
import.data = file:current:publicUrl
}
stdWrap.ifEmpty = {$settings.ext.news.imageDummy}
}
But is there a better way to do it, especially to get the data as an array of FileReferences? With a FAL FileReference i could also take crop an meta data into account.
You might use a FilesProcessor
example based on the manual:
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
as = news_images
references {
fieldName = fal_media
table = tx_news_domain_model_news
}
sorting = datetime
sorting.direction = descending
}
Although I can't imagine that this will be the correct way as there is no guarantee that the first news you select by this is the first news shown on the page. News have multiple conditions to be shown aside of basic visibility: ordering by publishing time, archived state, top-news state, groups or categories, ...
Maybe it would be easier if you use a news plugin with a special template and don't forget to enable showing of news multiple times (by default each news gets shown only once in a page)
Is it possible to configure which content element types are available for the content elements relation in tx_news records?
I have a backend layout which allows only gridelements in tt_content. The regular content elements are only allowed within a grid elements container.
Currently I face the problem, that in news records it's only possible to add grid elements:
I'd like to allow only some specific content elements in news records.
Update:
The above mentioned restriction is done via TSConfig for the BackendLayout:
mod.web_layout.BackendLayouts {
1 {
title = Standardseite
config {
backend_layout {
colCount = 1
rowCount = 1
rows {
1 {
columns {
1 {
name = Content
colPos = 0
allowed = gridelements_pi1
}
}
}
}
}
}
}
}
When I remove the line allowed = gridelements_pi1, all content element types are available again.
But regardless of the allowed setting for backend layouts I'd like to have just a small subset of content element types available for news records.
Sometimes the solution can be so simple and obvious! Thx for hint, Georg Ringer!
Just override the settings for the news sys folder:
[45 in tree.rootLineIds]
# this changes the allowed CTypes. Add more as a comma separated list
mod.web_layout.BackendLayouts.1.config.backend_layout.rows.1.columns.1.allowed = textmedia
# this sets the default CType to prevent an error with INVALID VALUE ("text")
TCAdefaults.tt_content.CType = textmedia
[global]
By the way, an even better solution would be to use TCEFORM.tt_content.CType.removeItem = ..., but this would require to update the list each time you add a new CType.
i have a little problem getting a custom content element via typoscript on all pages.
i´ve created a custom element without any extensions (like mask or dce) so im only using
TYPO3 core functions. This Element is a simple thingy that just uses irre for creating
different boxes to be displayed in the frontend.
tt_content.box = COA
tt_content.box {
10 = FLUIDTEMPLATE
10 {
file = EXT:xxx_elements/Resources/Private/Templates/Box.html
partialRootPath = EXT:xxx_setup/Resources/Private/Content/Partials
layoutRootPath = EXT:xxx_setup/Resources/Private/Content/Layouts
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tx_xxxelements_box
orderBy = sorting
where {
data = field:uid
intval = 1
wrap = tt_content=|
}
as = boxitems
}
}
}
}
rendered with normal fluid like
<f:for each="{boxitems}" as="boxitem">
<boxitem.header>...
</f:for>
so everything works fine as long as i use it as a regular content element that is placed
on a page. now i put one element into a storagefolder and try to reuse this element on all pages via typoscript
where 10 is the ID of the content element
lib.SubFooter = COA
lib.SubFooter {
10 = RECORDS
10 {
tables = tt_content
source = 10
}
}
the lib is rendered correct, but the "boxitems" array is empty on all pages :-(
now the funny part:
if i place the element with ID 10 on a page the boxitems array is filled for both element and lib...
Here is an image with the variable dump for different situations:
element, lib, element+lib
Unfortunately, I could not find a satisfactory solution to the problem. In the end, I have built the content element as a normal element instead of IRRE, then the integration with typoscript works as expected.
maybe you're missing the pid ;-)
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
....
pidInList.field = pid
and you can simplify in my opinion in this case the where clause:
where.dataWrap = tt_content={field:uid}
because you're not matching against vars from outside...
I have extended the TCA for every Backend-Page on the Page-Tree. One of the new Options is the "Page-Type", for example "PressPage". With this Extension, i have a new databasefield in the table "pages".
Now i would build an HMENU/TMENU with all pages, below this folder.
[...]
lib.MetaPressNavigation{
special = directory
special.value = ID_FROM_FOLDER_WITH_PAGETYPE_PRESSPAGE
[...]
But i have no idea to realize them with typoscript.
I hope anyone can help me.
Thanks.
EDIT:
Now - i have try it with an extended TCA. It's very easy for any User to make some configuration for this projectpage. The Users can set a value with an Checkbox in a special tab.
I have try to get the page out form the database, with this special config - any page have in the database on the column "tx_meta_pagetype the value 9. I need the UID from this page to build the META-Navigation. It will be full functional - when i give a hardcoded uid, but i need this dynamic.
This is my attemp, to get the UID from the database:
temp.MetaNavigationIds = CONTENT
temp.MetaNavigationIds{
table = pages
select.Where = tx_meta_pagetype = 9 #tx_meta_pagetype is set from the TCA
renderObj = TEXT
renderObj.field = uid
renderObj.stdWrap = |
}
lib.MetaNavigation = HMENU
lib.MetaNavigation{
special = directory
special.value < temp.MetaNavigationIds #the UID of configured page, that i need for the menu
1 = TMENU
1 {
wrap = <ul> | </ul>
NO{
wrapItemAndSub = <li> | </i>
wrapItemAndSub.insertData = 1
allStdWrap.insertData = 1
}
}
}
I have try a lot of database question with typoscript, but nothing works.
Be careful, special.value is not a content object but just a property. You are copying a content object (CONTENT) in its place. This does not work.
However it does have stdWrap. Therefore something like
special.value.stdWrap.cObject < temp.MetaNavigationIds
Should work out.
For renderObj.stdWrap = | enter renderObj.wrap = |, instead. Please mind the trailing comma. This will make sure that you actually get a comma separated list of uids. Otherwise your uids would be printed just after each other, thus forming one big number.
Please test each part individually before adding the components together. You should make sure that each pease returns the correct data, otherwise you will never get a working solution.
And of course select.Where must be select.where. Capitalization does matter.
Here is a working example for CONTENT:
page.10 = CONTENT
page.10 {
table = pages
select {
where = doktype = 199
recursive = 99
# Needs to be your root page uid
pidInList = 1
}
renderObj = TEXT
renderObj.field = uid
renderObj.wrap = |,
}
If you are using TYPO3 6.2, I would recommend to use the new category system. You can create different categories in the TYPO3 backend and assign those categories to your pages.
With this, you can create a HMENU/TMENU like shown below:
20 = HMENU
20 {
special = categories
special.value = 1,2
1 = TMENU
1.NO {
...
}
}
If you do not use TYPO3 6.2 or do not want to use the category system, you can use a userfunction to return the pages which matches your "Page-Type".
HMENU/TMENU TypoScript will be like shown below.
lib.leftmenu.20 = HMENU
lib.leftmenu.20.special = userfunction
lib.leftmenu.20.special.userFunc = user_myspecialmenu_pi1->getPressPages
The TypoScript above is just an example, and you need to code the userfunction your own.
A detailed reference of the special property userfunction is available here and a example can be found here.
I want to output a string to the rendered HTML by using two fallbacks.
My typoscript is defined at the top level page (root page of my website) and is passed to all pages at lower levels.
Structure:
Homepage
Page at level 1
Page at level 2
Regular output of the file:
The string comes from a TemplaVoila field (Page / Edit / Extended / MyField): field_copyright_name
To output it to the desired point in the HTML output a templaVoila mapping exists (Type: Typoscript Object Path), named: lib.copyright_name
The following typoscript does the job:
lib.hint_copyright_name = COA
lib.hint_copyright_name.10 = TEXT
lib.hint_copyright_name.10 {
setCurrent.dataWrap = {field:field_copyright_name}
current = 1
}
This works for all pages at all levels where the field (in page properties) is not empty.
The first fallback:
If the field is empty (in properties of that page, e.g. at level 2) typoscript should get the value from the pages above (at level 1, and if it is empty too, it should get it from homepage). No clue how to do it. Can you help?
The second fallback
If the first fallback still returns an empty string (because the field was empty at all levels) it should do a fallback to a default value "Copyright by me".
To enable this fallback without "first fallback" is easy:
switchdefault_copyright_name = TEXT
switchdefault_copyright_name {
setCurrent.dataWrap = {field:field_copyright_name}
current = 1
override = "Copyright by me"
override.if.isFalse.field = field_copyright_name
}
lib.hint_copyright_name = COA
lib.hint_copyright_name.10 < switchdefault_copyright_name
But how to integrate the "first fallback"?
EDIT:
I tried:
setCurrent.data = {levelfield:-1, field_copyright_name, slide}
or
setCurrent.data = levelfield:-1, field_copyright_name, slide
or
setCurrent.dataWrap = {levelfield:-1, field_copyright_name, slide}
or
setCurrent.dataWrap = levelfield:-1, field_copyright_name, slide
but without success - no output.
Just found this : http://lists.typo3.org/pipermail/typo3-english/2006-October/032764.html
It's supposed to make youre slide thing to work.
Just set : Installation > all configuration > addRootLineFields
Didn't tried it, but seems like the solution