TYPO3 Custom Menu Element - typo3

I am trying to create a custom menu element by using this in the Page TSConfig:
TCEFORM.tt_content {
menu_type.addItems.101 = My Menu
}
And this in Setup:
temp.my_menu = HMENU
temp.my_menu {
special = list
special.value.field = pages
1 = TMENU
1 {
wrap = <ul> | </ul>
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
}
tt_content.menu.20.101 < temp.my_menu
But I get 'Oops, an error occurred!' where the menu should be.
It will render fine if I remove the Fluid includes in the template but then all the other content elements give errors.
Is there any way to have a typoscript menu element at the same time as fluid styled content?
Or if I really have to, how do I add a custom fluid menu template?

You need to move the line with the copy operation down to the bottom, otherwise the configuration is not copied, because it is not there yet.
The exception happens, because there is no rendering definition for the menu (because you never copied the configuration).
To see the real error instead of the exception, switch to the development preset in the install tool oder add the following line to your TS setup:
config.contentObjectExceptionHandler = 0

I noticed this :
TCEFORM.tt_content {
menu_type.addItems.101 = My Menu
}
as far as I know should be this :
TCEFORM.tt_content.menu_type {
types {
menu{
addItems {
101 = My Menu
}
}
}
}
I had to 'tweak' the special menus (typo3 7.6) and this worked:
Add special menu and add class="active" in TYPO3

Related

TYPO3 render Event from typoscript and Fluid template

In TYPO3 10.4.8 I have the following page tree:
root
1level: Events
2level: Event A, Event B, Event C, ... and so ...
What I want to do in page Events is to render all subpages title, using FLUIDTEMPLATE.
So in the template of page Events I wrote
lib.EventContent = COA
lib.EventContent {
10 = COA
10{
table = pages
select {
orderBy = sorting
pidInList = this
}
}
}
and in the layout file
<f:for each="lib.EventContent" as="event" >
<p>event: {event.title}</p>
</f:for>
This doesn't work. Typo give me this error:
The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper".
In addition, I also tried to change COA with CONTENT, in all possible combination (COA-CONTENT / CONTENT-COA / CONTENT-CONTENT)
What's wrong? is something that I cannot do?
Thanks all
The TypoScript should look something like this:
lib.EventContent = CONTENT
lib.EventContent {
table = pages
select {
orderBy = sorting
pidInList = this
}
}
But there is a much easier solution. TYPO3 already brings a content element "Subpages" which renders a menu of all subpages of a selected page:
This is done via Fluid Styled Content and TypoScript. Please check this file for details:
typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/MenuSubpages.typoscript
A solution for you might look like this (untested):
lib.EventContent < tt_content.menu_subpages
lib.EventContent {
dataProcessing {
10 {
special >
}
}
}
It's also a good idea to have a look in all the TypoScript files in the Fluid Styled Content extension to get more inspiration.

TYPO3 determine page type of menu item and wrap div with custom class around it

My goal is to apply different navigation logic to different page types. For example shortcut type will be container (drop down list in FE, shortcut itself is dummy link), standard type - page with content that you can navigate to. So, when in FE navigation user selects page:
drop-down list appears
if (type of page in list == standard)
can navigate to page in list;
else if (type of page in list == shortcut)
GO TO drop-down list appears
I know that you can do something like this:
lib {
main-nav = HMENU
main-nav {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
NO.stdWrap.cObject = CASE
NO.stdWrap.cObject {
key.field = doktype
default = TEXT
default {
field = title
}
# standard page type
1 = TEXT
1 {
field = title
wrap = <div>|</div>
}....
As a result you get page title wrapped with div if page type is standard.
But what do i need to do to wrap whole menu item rather then just wrapping title?
If it's just about putting the div around the whole submenu, I guess what you already got should be applied to wrapItemAndSub instead
lib {
main-nav = HMENU
main-nav {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.wrapItemAndSub.cObject = CASE
NO.wrapItemAndSub.cObject {
key.field = doktype
default = TEXT
default {
value = <li>|</li>
}
# standard page type
1 = TEXT
1 {
value = <li><div>|</div></li>
}....
I think you need to combine HTML, CSS and javascript.
In the typoscript you prepare the HTML with different markup depending on page type. Then your javascript has to handle the click event in case of a shortcut page where a click should open a drop down instead of going to that page. (add eventhandler)
So you need to give javascript something to identify the shortcut pages.
With the CASE object you mentioned you can build the apropiate HTML with all neccessary information (you might use data- attributes).
For a more detailed help you need to be more specific what you want to achieve.

Override HMENU that is included in another template

In TYPO3 4.7 I have a template that contains:
page.10 < temp.mainTemplate
This Template has two includes. The first contains this:
temp.mainTemplate = TEMPLATE
temp.mainTemplate {
subparts.menu_1 < temp.menu_1
}
And the second contains the actual HMENU typoscript:
temp.menu_1 = HMENU
temp.menu_1 {
#My Menu
}
Without altering either of the includes, how can I make an edit to the HMENU in the main template setup?
I have tried this above the first line without success:
temp.mainTemplate.subparts.menu_1 {
#Modifications to My Menu
}
I have tried this below the first line without success:
page.10.subparts.menu_1 {
#Modifications to My Menu
}
page.10.subparts.menu_1 is the right key to alter. It needs to be places after page.10 < temp.mainTemplate of course.
you can test it by deleting the menu completely with page.10.subparts.menu_1 > and it should disappear from the webpage.
There is no way of telling what exactly does not work without seeing more of your TS. May be you have just a typo somewhere

How to hide a plugin's title via Typoscript when rendering with css_styled_content

This is probably very basic, but I'm stuck.
In TYPO3 6.1.x with tx_news, I have configured the news detail view to appear on the same page as the list view as taught on http://docs.typo3.org/typo3cms/extensions/news/latest/Main/Tutorial/IntegrationWithTs/Index.html
Also, I have pulled in the news'header as h1 as such
temp.h1 = COA
temp.h1 {
10 = TEXT
10 {
value = <h1>{page:title}</h1>
insertData = 1
}
10 = RECORDS
10 {
if.isTrue.data = GP:tx_news_pi1|news
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
wrap = <h1>|</h1>
}
}
What I couldn't solve yet is that the plugin element has a title (in the regular "header" field). I need to display this header only in the list, but hide that plugin's header field in detail view.
How / where can I do that via page TS?
This is probably not even in the plugin, but in css_styled_content?
Something like this...
[globalVar = GP:tx_news_pi1|news > 0]
plugin.tx_news.stdheader >
[else]
But how?
A plugin is always using this prototype object:
tt_content.list
Therefore you could delete the header of this object like that
tt_content.list.10 >
But if you have other plugins on the same page, their headers would also be deleted. So that would be a bad idea.
I would suggest you use the header_layout field. By default it has an entry called "Hidden" that will hide the header of your plugin. If you don't have it, check the Page TypoScript configuration. You can add own items by using:
TCEFORM.tt_content.headerLayout.addItems.99 = My Header Layout
Then you can then define the rendering of your own layouts in
lib.stdheader.10
(it's a CASE object)

typo3 show submenu without subpages

I have a website with some pages, presented in a normal menu. Every page has subpages and shows them in a submenu. Except one page. This page has no subpages and should have a content menu which navigates to different content sections on the page. The thing with the content navigation is done with:
temp.contentnav = CONTENT
temp.contentnav {
table = tt_content
select {
pidInList = 7
orderBy = sorting
where = colPos=0
languageField=sys_language_uid
}
renderObj = TEXT
renderObj {
field = header
wrap= <li>|</li>
typolink.parameter.field=pid
typolink.parameter.dataWrap=|#{field:uid}
typolink.ATagParams = class="linkSubpage"
if.isTrue.field=header
}
wrap = <ul id="subMenu"> | </ul>
}
page.10.marks.MENU.2a.NO.after.cObject < temp.contentnav
but this works only if the page has at least one subpage. The workaround would be to add a subpage and hide the submenulink, but is there a better solution to show the custom submenu without adding subpages?
Use a HMENU item with the levels to generate your submenu.
Your behavior is not the right one in the TYPO3 working style. Use the rights TypoScript objects.
And remove the "a" from the "page.10.marks.MENU.2a.NO". The correct use is 1,2,3,...
http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/CommonProperties/Index.html
http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/CommonItemStates/Index.html
http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/Tmenu/Index.html
http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/Tmenuitem/Index.html