TYPO3 Hide & Replace Pagetitle in Breadcrumb - typo3

I have a little problem with my navigation and couldn't get it work...I got on every page a breadcrumb navigation which shows the page tree until the current page.
So far so good but when I go to the details page of my news I got the following tree Home > Newest > Article. I don't want to have the page title Article here because every other news would have this tree. Instead of the pagetitle I want to have the news title so I modified my navigation like this:
30 = HMENU
30 {
special = rootline
special.range = 0 | -1
1 = TMENU
1 {
stdWrap.dataWrap = <p>{ date : d.m.Y } ::: |
NO = 1
NO {
wrapItemAndSub = | >
stdWrap.htmlSpecialChars = 1
}
CUR = 1
CUR.allWrap = | </p>
stdWrap.append = RECORDS
stdWrap.append {
if.isTrue.data = GP:tx_news_pi1|news
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
}
}
}
}
And now the problem: when I click go on a page which is hidden in menus the breadcrumb looks like this Home >. Obviously the last page isn't displayed and this should be solved but I don't know how to do it.
At least I tried something with this in some combinations but cant't get it work
if {
value = 46
equals.field = uid
excludeUidList = 46 //includeNotInMenu = 1
}
When adding includeNotInMenu = 1 under the special.range hidden pages are shown in the breadcrumb title but then the breadcrum in news looks like this Home > Newest > Article NewsTitle and I don't want to have this 'Article' in it. Hope someone of you can help me!

first:
not displaying the current page is ok only for the news-detail page. so use a condition to realize it:
[page|uid = 123]
30.30.special.range = 1|-2
[global]
second:
add the current news title after the menu. the handling is a littel bit easier.
30.40 = RECORDS
30.40 {
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
}
}
therefore you might need to change the wrap. either split it or (better) give it an additional COA level.
and so the news title only is neccessary on your detail page you put that code into the condition.
Alternatives:
you can use .stdWrap.if to modify the range of the breadcrumb and the display of the news title, but with the TS-condition you have a smaller typoscript for normal pages (faster rendering).
You even need no condition for the tx_news_pi1|news parameter, as the detail page normaly would not show anything (except an error)

For example (since Ext news 7.2) to hide News Detail page in the breadcrumb..
Home > News > News Detail > Article name
page.10.dataProcessing {
100 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
100 {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
as = breadcrumb
}
110 = GeorgRinger\News\DataProcessing\AddNewsToMenuProcessor
110.menus = breadcrumb
}
[page["uid"] == {$pages.newsDetail}]
page.10.dataProcessing.100.special.range = 0|-2
[END]
Results in
Home > News > Article name

Related

TYPO3 TypoScript: Display a list of subpages with content on parent page

I am trying to create an archive page that displays a list of subpages, similar to WordPress but display the parent's subpages instead of posts. I want the archive page to include the following from the subpage:
Title
First image
First 150 words of regular text element
At the moment I can display a page title, but that's where I got stuck. I am placing the code in a sub template. Here is the code.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
pidInList = this
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.wrap = <div class="project">|</div><hr />
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
10.typolink.parameter.field = uid
}
}
If it helps, all of the images are within the fileadmin/user_upload/ directory, and this is my page structure:
Root
Home
About
Project Portfolio
Project 1
Project 2
Blog
Contact Us
Seems like I figured it out myself, all I had to do was call for content in a separate query. For those that are looking to achieve something similar, here is the code I used to help you out.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
orderBy = sorting ASC
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.allWrap = <div class="row">|</div>
stdWrap.wrap = <div class="project col-lg-6 col-md-6 col-sm-12 col-xs-12">|</div>
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
typolink.parameter.field = pages.uid
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
selectFields = header, bodytext
orderBy = sorting ASC
}
renderObj = COA
renderObj {
30 = TEXT
30.value {
field = bodytext
wrap = <div>|</div>
}
}
}
}

TypoScript menu, with special treatment for specific pageIDs contained in list

Tearing my hair out over a TypoScript menu. I need the following behaviour:
A list of "special" menu items pageIDs is maintained in constant {$SPECIAL}
A HMENU is rendered showing the navigation of the site root. If the pageID is "special", then it gets a special div wrap, and a list of its child pages is nested inside of the div wrap. If the item is NOT "special", then it gets no special wrap, and no child pages are shown. All "special" items are shown at the top of the page list.
I've tried a couple of approaches:
Approach 1. Render two HMENUs, one after the other. First menu shows only {$SPECIAL}, second menu shows the siteroot, excluding the {$SPECIAL} items.
Problem: if I use special.directory to show {$SPECIAL}, the parent pages are not rendered. If I use special.list, the child pages are not rendered. Argh!
Approach 2. Render a big chunk of custom menu TS, using if conditions to check if the page is {$SPECIAL}
Problem: I can get the special wraps to show on {$SPECIAL} items, but I can't work out how to then render a list of the child pages specific to each item.
My code for Approach 2 is, so far:
MAIN_NAV.20 = HMENU
MAIN_NAV.20 {
special = directory
special.value = {$SITE_ROOT}
excludeUidList = {$RESTRICTED_ROOT}, {$HOME_SHORTCUT}
1 = TMENU
1{
NO{
# suppress standard menu output
doNotShowLink = 1
# build each menu item conditionally
stdWrap2.cObject = COA
stdWrap2.cObject{
#Standard
10 = TEXT
10{
# not in list of special pages?
if.value = {$NAV_CONTAINERS}
if.isInList.field = uid
if.negate = 1
field = nav_title//title
typolink.parameter.field = uid
wrap = <ul><li>|</li></ul>
}
#Special
20 = TEXT
20.wrap = <div class="SPECIAL"><ul><li><span>|</span>
20 {
if.value.field = uid
if.equals = {$SPECIAL}
field = nav_title//title
}
30 = TEXT
30.wrap = |</li></ul></div>
30 {
if.value.field = uid
if.equals = {$SPECIAL}
}
}
}
}
}
I can't hardcode this (like "Special item 1 as a text element, then Special item 1 children as a menu, then Special item 1 as a text element, then Special item 2 children...") because {$SPECIAL} could theoretically wind up being any number of pages.
Can anyone offer any suggestions to assist with one or other approach?
I think user Ila is right, if you use special = list, you should be able to add multiple levels (child pages) by adding TMENUs.
On the other hand, I've got a similar menu I'd like to share. It contains two kinds of special rendering cases - one with override.if and the other one with CASE.
temp.mainnav = HMENU
temp.mainnav {
wrap = <nav>|</nav>
entryLevel = 0
1 = TMENU
1 {
noBlur = 1
expAll = 1
wrap = <ul>|</ul>
NO {
wrapItemAndSub=<li class="p{page:uid}">|</li>
wrapItemAndSub.insertData = 1
}
}
2 = TMENU
2 {
noBlur = 1
expAll = 1
NO {
wrapItemAndSub=<li>|</li>
// http://labor.99grad.de/2013/07/10/typo3-hmenu-einen-menupunkt-anders-darstellen/
doNotLinkIt.override = 1
doNotLinkIt.override.if {
value = {$pidsDoNotLinkInMenu}
isInList.field = uid
}
stdWrap.wrap.override = <p class="unlinkedMenuItem">|</p>
stdWrap.wrap.override.if {
value = {$pidsDoNotLinkInMenu}
isInList.field = uid
}
}
}
3 = TMENU
3 {
noBlur = 1
expAll = 1
wrap = <ul class="level3">|</ul>
NO.wrapItemAndSub.cObject = CASE
NO.wrapItemAndSub.cObject {
//http://stackoverflow.com/questions/18899573/how-to-apply-a-different-wrap-in-a-tmenu-for-certain-items-only/18910302?noredirect=1#18910302
key.field = uid
// normal item
default = TEXT
default.value = <li class="level3">|</li>
// special item
{$somePid} = TEXT
{$somePid}.value = <li class="level3 foo">|</li>
{$somePid}.append < temp.sometemp
// some other special item
{$someOtherpid} = TEXT
{$someOtherpid}.value = <li class="level3 bar">|</li>
{$someOtherpid}.append < temp.someothertemp
}
}
}
I think both approaches could be used to achieve your goal.

TYPO3: Show content from a fixed page if there’s no content on current page

I would like to show content from a fixed page if there’s no content on current page.
An example: On the mainpage (pid=58) In the right col (colPos=31) I have a news plugin with the latest item. On subpages, it’s possible to insert content in the right col (colPos=31). It could be images,text etc. BUT, if the right col is empty I would like to show the news plugin from the mainpage as a fallback option.
This is my TypoScript, but it doesn’t work. Default content from mainpage are not showed, if there's no content from current page.
lib.rightCol-1 = COA
lib.rightCol-1 {
10 = COA
10 {
## Get content from current page.
10 = COA
10 < styles.content.get
## Get content from colPos 31
10.select.where = colPos=31
if.isTrue.current = 1
20 = CONTENT
20 {
## IF no content on current page show content from mainpage
stdWrap.if.isTrue.current = 1
stdWrap.if.negate = 1
table = tt_content
select {
## Get content from mainpage
pidInList = 58
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
}
}
}
This can be done using stdWrap.override. If stdWrap.override returns something non-empty, this value replaces the normal value stdWrap would return. In your case, this could look like this:
# Fetch the default content from the mainpage with id 58
lib.rightCol-1 = CONTENT
lib.rightCol-1 {
table = tt_content
select {
pidInList = 58
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
# override the content from page 58 with content from the current page,
# but only if there is content on this page
stdWrap.override.cObject = CONTENT
stdWrap.override.cObject {
table = tt_content
select {
pidInList = this
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
}
}
You can also create the following behaviour:
If there is content on the current page, show it.
Else, walk up the rootline and take the content from the first page that has content in the column.
If there is no such page, take the content from the "mainpage".
This can be done by simply setting slide = -1 to the second CONTENT-Object.
Thanks for answer but I couldn't get it to work. Instead this worked:
lib.rightCol-1 = CONTENT
lib.rightCol-1 < styles.content.get
lib.rightCol-1.select.where = colPos=31
lib.rightCol-1 {
stdWrap.ifEmpty.cObject = CONTENT
stdWrap.ifEmpty.cObject {
table = tt_content
select {
pidInList = 58
orderBy = sorting
where = colPos = 31
languageField = sys_language_uid
}
}
}

Typoscript menu jump to subpage

I want to create a menu with submenu, that's quiet straight forward via typoscript. The challenge is, that I want the parent levels to link directly to the first subpage if the content of the containing page is empty.
I know you can achieve that via shortcut links in the backend, but I want to, if possible, achieve that via typoscript.
Any ideas? I enclode the typoscript menu code I currently use.
lib.mainMenu = COA
lib.mainMenu{
10 = HMENU
10{
# Level 1, further levels are generic
1 = TMENU
1.noBlur = 1
1.expAll = 0
1.wrap = <ul data-role="listview" data-inset="true">|</ul>
1.NO = 1
1.NO.ATagBeforeWrap = 1
1.NO.insertData = 1
1.NO.wrapItemAndSub.insertData = 1
1.NO.wrapItemAndSub = <li id="menu_{field:uid}">|</li>
1.NO.ATagTitle.field = subtitle // title
1.ACT = 1
1.ACT.ATagBeforeWrap = 1
1.ACT.wrapItemAndSub.insertData = 1
1.ACT.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li>
1.ACT.ATagTitle.field = subtitle // title
1.CUR = 1
1.CUR.ATagBeforeWrap = 1
1.CUR.wrapItemAndSub.insertData = 1
1.CUR.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li>
1.CUR.ATagTitle.field = subtitle // title
}
20 < .10
20.entryLevel = 1
20.1.wrap = <ul data-role="listview" data-inset="true">|</ul>
30 < .20
30.entryLevel = 2
40 < .20
40.entryLevel = 3
}
Maybe you can build your solution based on hints from here:
http://typo3-blog.net/tutorials/news/if-funktionen-in-typo3.html
In the example from the link above, it's not a menu, but there's a subquery on a table (in your case tt_content) which will then be used to define if something's output or not:
temp.main = COA
temp.main.20 = COA
temp.main.20 {
[...]
wrap=<div class="meine-adressen">|</div>
stdWrap.if.isTrue.cObject = CONTENT
stdWrap.if.isTrue.cObject{
table = tt_address
select {
[...]
}
renderObj = TEXT
renderObj.value = 1
}
}
temp.main.21 = TEXT
temp.main.21 {
wrap=<div class="keine-adressen">|</div>
value = Keine Adressen gefunden
stdWrap.if.isFalse.cObject < temp.main.20.stdWrap.if.isTrue.cObject
}
But I'm not sure if this wouldn't give you headaches in a HMENU
I think it is possible using typoscript, but I dont know how to do it.
The below typoscript may help you:
Typoscript to find the number of content elements in a page:
lib.emptypage = CONTENT
lib.emptypage{
table = tt_content
select{
selectFields = count(uid) AS count
pid = id
}
renderObj = COA
renderObj {
10 = TEXT
10 {
value = {field:count}
insertData = 1
}
}
wrap = |
}
If count is equal to zero, then the page is empty.
Typoscript to get the first subpage:
lib.firstsubpage= HMENU
lib.firstsubpage {
maxItems = 1
1 = TMENU
1 {
NO = 1
}
}
Please share your typoscript solution after implementing it.

HMENU with graphics

In a TYPO3 site, I have a list of sibling pages. Each page has some images in the "media" field. Im trying to make a navigation to go to the previos/next sibling. So far I have this:
# Append Sitenavi for projects
[PIDupinRootline = 43]
page.10.marks.MAIN.20 = HMENU
page.10.marks.MAIN.20{
special = browse
special{
items = next|prev
}
1 = TMENU
1{
NO = 1
}
}
[global]
But instead of using the page title, id like to use the first image from the "files" field. How could I do it?
This is the way to get other fields:
page.10.marks.MAIN.20 = HMENU
page.10.marks.MAIN.20 {
special = browse
special {
items = prev | next
}
1 = TMENU
1 {
NO = 1
NO.stdWrap.field = subtitle // title
}
}
Now if your change subtitle // title to image and add NO.stdWrap.wrap = <img src"|" />, then it should work.