TYPO3 News Title in breadcrumb with MenuProcessor - typo3

is it possible to show the current news title in breadcumb with the MenuProcessor?
I've tried some with DatabaseQueryProcessor but I don't get the data.
Have someone a working example or a tutorial for me?
At the moment I have only this:
temp.breadcrumb = FLUIDTEMPLATE
temp.breadcrumb {
templateName = breadcrumb
templateRootPaths {
10 = fileadmin/resources/private/template/menu/
}
partialRootPaths {
10 = fileadmin/resources/private/template/partials/
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
as = menuBreadcrumb
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = records
table = tx_news_domain_model_news
}
}
}
}

Related

How do I override HMENU Special setting based on layout?

I have a menu element that is set to list the selected pages.
tt_content.my_menu {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = list
special.value.field = pages
}
}
}
How can I change this to a directory of pages when a specific layout is set?
tt_content.my_menu {
dataProcessing {
10 {
special {
override = directory
override.if.value = my-layout
override.if.equals.field = layout
}
}
}
}
I'm not sure if MenuProcessor? has stdWrap on its properties.
But it should be possible to define two processors, each with an if:
tt_content.my_menu {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
if {
value = my-layout
equals.field = layout
negate = 1
}
special = list
special.value.field = pages
}
20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
20 {
if {
value = my-layout
equals.field = layout
}
special = directory
special.value.field = pages
}
}
}

TYPO3 Menu with categories?

How can I add the categories to each page of my menu element?
I have been trying different combinations of DatabaseQueryProcessor but the array comes through empty.
This is what I currently have based on other examples:
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = list
special.value.field = pages
levels = 2
as = menuItems
expandAll = 1
includeNotInMenu = 1
titleField = nav_title // title
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
if.isTrue.field = categories
table = sys_category
pidInList = root,-1
selectFields = sys_category.*
where.data = field:_ORIG_uid // field:uid
as = categories
}
}
}
}
The pidInList needs to be the page where the categories are stored.
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
if.isTrue.field = categories
table = sys_category
selectFields = sys_category.*
pidInList = 55
recursive = 999
join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
where.data = field:_ORIG_uid // field:uid
where.intval = 1
where.wrap = sys_category_record_mm.uid_foreign=|
as = categories
}

How to configure category-list (TYPO3 news extension) via TypoScript

I have a blog page on one of the websites which is done using TypoScript to avoid having a list and detail page.
I have called the TypoScript as an object: lib.newslist.
plugin.tx_news.settings.list.paginate.itemsPerPage = 6
lib.news = USER_INT
lib.news {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = Pi1
vendorName = GeorgRinger
extensionName = News
controller = News
settings < plugin.tx_news.settings
settings {
categories = 1
#limit = 6
detailPid = 6
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 21
hidePagination = 0
categoryConjunction = or
}
persistence =< plugin.tx_news.persistence
view =< plugin.tx_news.view
}
[(request.getQueryParams()['tx_news_pi1'])['news'] > 0 || (request.getParsedBody()['tx_news_pi1'])['news'] > 0]
lib.newslist = COA
lib.newslist {
10 < lib.news
10 {
action = detail
switchableControllerActions.News.1 = detail
stdWrap.wrap = <section class="blog-section"><div class="container">|</div></section>
}
20 = RECORDS
20 {
source = 307
dontCheckPid = 1
tables = tt_content
}
}
[else]
lib.newslist < lib.news
lib.newslist {
action = list
switchableControllerActions.News.1 = list
stdWrap.wrap = <div class="section-heading mb-5"><h2>Blog</h2></div>|
}
[end]
[else]
lib.newslist = COA
lib.newslist {
action = list
switchableControllerActions.News.1 = list
stdWrap.wrap = <div class="section-heading mb-5"><h2>Blog</h2></div>|
}
[end]
Now I needs to add a category list to this. So I have added the following TypoScript:
lib.categoryMenu = USER
lib.categoryMenu {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
action = category
switchableControllerActions {
Category {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
listPid = 6
}
}
The problem in this is there is no list page or detail page, so what will I give instead of the listPid = 6 (6 is the page from which I called the TypoScript objects).
And please suggest if there is any other method to implement this category selection without specifying the list page.

Override FILES references.data with fallback

I get the images for a slider via data = level media:-1,slide
On a news-single-page I want to use the news-images instead of. So I put the code for this in conditions [globalVar = GP:tx_news_pi1|news > 0] and get the images of the news. All ok. But I want to show the level media, if there is no news-image. How can I do this?
Here’s the TypoScript:
lib.keyVisual = COA
lib.keyVisual {
10 = FILES
10 {
references {
data = levelmedia:-1,slide
}
renderObj = COA
renderObj.10 = IMAGE
renderObj.10 {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = {$keyVisualWidth}
#width.field >
height = {$keyVisualHeight}
}
}
renderObj.20 = COA
renderObj.20 {
1 = TEXT
1 {
data = file:current:title
required = 1
wrap = <h3>|</h3>
}
2 = TEXT
2 {
data = file:current:description
required = 1
wrap = <p>|</p>
}
stdWrap.wrap = <div class="imageCaptionBox">|</div>
stdWrap.required = 1
}
renderObj.wrap = <li>|</li>
}
wrap = <section id="keyvisual" class="keyvisual fullWidth"><ul class="slider nav">|</ul></section>
}
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
10 {
references {
data >
table = tx_news_domain_model_news
uid.data = GP:tx_news_pi1|news
fieldName = fal_media
}
# only images with showinpreview
renderObj.if {
value = 1
equals.data = file:current:showinpreview
}
}
}
[global]
Work with the ifEmpty stdWrap option.
If your COA is empty you can render the default image with this option.
simple example to explain:
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
stdWrap.ifEmpty.cObject < .10
#overrides for news picture
10 {
...
}
}
[global]
all conditions have an [else] so you do not need to redefine.
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
... from news...
}
[else]
lib.keyVisual {
... from levelmedia ...
}
[global]
then you need to distinguish wether an image is availabel for the news.
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual = COA
lib.keyVisual {
10 = CONTENT
10 {
// get news record and then get file
... from news...
if.empty.field = media
}
20 = FILES
20 {
... from levelmedia ...
if {
empty.field = media
negate = 1
}
}
}
[else]
lib.keyVisual {
... from levelmedia ...
}
[global]
that could be optimized by using a temp object for the levelmedia usage which gets copied.
temp.levelmediaImage {
...
}
[globalVar = GP:tx_news_pi1|news > 0]
kib.keyVisual = COA
lib.keyVisual {
10 = CONTENT
10 {
// get news record and then get file
... from news...
if.empty.field = media
}
20 < temp.levelmediaImage
20 {
if {
empty.field = media
negate = 1
}
}
}
[else]
lib.keyVisual < temp.levelmediaImage
[global]

Fallback image in typoscript

I have the following menu-type, which works correctly for the main-part.
However, i want to add a fallback image, if no image is found.
tt_content.menu {
20 {
108 = HMENU
108 {
special = directory
special.value.field = pages
1 = TMENU
1.wrap = <div class="special_menu">|</div>
1.NO {
doNotLinkIt = 1
stdWrap.cObject = COA
stdWrap.cObject {
10 = FILES
10 {
references {
table = pages
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
width = 263c
height = 155c
maxW = 263c
maxH = 155c
import.data = file:current:publicUrl
# if file:current:publicUrl is empty, use default image
if.isFalse = fileadmin/my/path/to/image.jpg
}
altText.field = title
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink.parameter.field = uid
}
}
stdWrap.wrap = <div class="menu10_bild">|</div>
}
20 = TEXT
20.field = title
20.typolink.parameter.field = uid
20.wrap = <div class="menu10_text">|
30 = TEXT
30.field = abstract
30.wrap = <p>|</p></div><div class="w-clearfix"> </div>
}
}
}
}
}
for some reason, it just ignores the line. Can someone help me with that?
You should check the TypoScript Reference stdWrap.ifEmpty.
In your case the code should look like this
tt_content.menu {
20 {
108 {
1.NO {
stdWrap.cObject {
10 = FILES
10 {
# ....
stdWrap.ifEmpty.cObject = IMAGE
stdWrap.ifEmpty.cObject{
file = fileadmin/.../my_image.png
}
# ....
}
}
}
}
}
}
You can use every cObject you want.
Check out Content Objects (cObject)
Try this:
tt_content.menu {
20 {
108 = HMENU
108 {
special = directory
special.value.field = pages
1 = TMENU
1.wrap = <div class="special_menu">|</div>
1.NO {
doNotLinkIt = 1
stdWrap.cObject = COA
stdWrap.cObject {
# default image
value = fileadmin/my/path/to/image.jpg
10 = FILES
10 {
references {
table = pages
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
width = 263c
height = 155c
maxW = 263c
maxH = 155c
import.data = file:current:publicUrl
}
altText.field = title
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink.parameter.field = uid
}
}
stdWrap.wrap = <div class="menu10_bild">|</div>
}
20 = TEXT
20.field = title
20.typolink.parameter.field = uid
20.wrap = <div class="menu10_text">|
30 = TEXT
30.field = abstract
30.wrap = <p>|</p></div><div class="w-clearfix"> </div>
}
}
}
}
}