Typoscript DatabaseQueryProcessor - slide if field is empty - typo3

I have a mm relation field in my page settings.
$myext_pages_fields = array(
'tx_myext_topofferitem' => Array(
'label' => 'Relation',
'config' => Array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_myext_topofferitem',
'MM' => 'tt_content_tx_topofferitem_mm',
'size' => '20',
'maxitems' => '99',
'show_thumbs' => '1',
'suggestOptions' => [
'default' => [
'searchWholePhrase' => 1
],
'pages' => [
'searchCondition' => 'doktype = 1'
]
],
)
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $myext_pages_fields);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', '--div--;Top Offers,tx_myext_topofferitem');
If the field is empty - the items of the next filled rootline page should be given.
To get the items i use the DatabaseQueryProcessor like that.
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
200 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
200 {
table = tx_myext_topofferitem
pidInList = root,-1
recursive = 99
selectFields = tx_myext_topofferitem.*
join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
where.data = field:uid
where.intval = 1
where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
orderBy = tt_content_tx_topofferitem_mm.sorting
as = tx_myext_topofferitem_items
}
}
}
I tried to use this as where.data, but this does not work.
levelfield : -1 , uid, slide
(TYPO3 9LTS)

It seems that it's better to make use of nested data processing here. So first get a rootline menu and then fetch the items that belong to a specific page of that menu.
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = rootline
special.range = 0|-1
special.reverseOrder = 1
as = rootline
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = tx_myext_topofferitem
table = tx_myext_topofferitem
pidInList.field = uid
selectFields = tx_myext_topofferitem.*
join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
where.data = field:uid
where.intval = 1
where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
orderBy = tt_content_tx_topofferitem_mm.sorting
as = tx_myext_topofferitem_items
}
}
}
}
}
}

Related

How to load post ID using the gform_form_post_get_meta filter?

Trying to load post ID (and then some ACF field) of the post, where the form is currently embedded. Using get_the_id() or global $post w/ $post->ID returns NULL.
Loading post ID works correctly when using the other Gravity Forms filters (e.g. gform_admin_pre_render), but I was told using the gform_form_post_get_meta is the better way to do ths. What is the right approach for this?
add_filter( 'gform_form_post_get_meta' , 'my_populate_cpt_as_choices' );
function my_populate_cpt_as_choices( $form ) {
$current_post_id = get_the_id();
$postargs = array(
'post_type' => 'suhlasy',
'post_status' => 'publish',
'posts_per_page' => '-1',
);
$posts = get_posts( $postargs );
$input_id = 1; // this makes sure the checkbox labels and inputs correspond
foreach ( $posts as $post ) {
//skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs)
if ( $input_id % 10 == 0 ) {
$input_id++;
}
$post_id = $post->ID;
$id_souhlasu = 1200 + $input_id;
$title = get_the_title($post_id);
$checkbox_text = get_field('checkbox_text', $post_id);
$text_suhlasu = get_field('text_suhlasu', $post_id);
$kategoria = get_field('kategoria_suhlas', $post_id);
// getting other fields for this post to display as values or checkbox labels
$nazev_souhlasu = GF_Fields::create( array(
'type' => 'consent',
'id' => $id_souhlasu, // The Field ID must be unique on the form
'formId' => $form['id'],
'isRequired' => true,
'label' => $title,
'parameterName' => 'my_custom_parameter',
'checkboxLabel' => $checkbox_text,
'description' => '<h2>' . $current_post_id . $post_id . $kategoria . '</h2><br>' . $text_suhlasu,
'pageNumber' => 1, // Ensure this is correct
) );
$form['fields'][] = $nazev_souhlasu;
$input_id++;
}
return $form;
}

TypoScript MenuProcessor special = directory :: page type shortcut

I've defined the following typoscript or my ce:
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
20 {
references.fieldName = teaser_image
as = teaserImage
}
}
}
}
The value for pages comes from the configuration in the be (select page from pagetree).
This works well, but if a page with type shortcut (4) is selected, nothing will be generated. I am looking for a way to achieve that if a shortcut is selected, the menu for the target page of this shortcut is being generated.
I want to solve this explicitly for the page type shortcut, not for the page type mountpoint. Unfortunately, I still don't get any data in the variable menu when the page type is shortcut.
For clarification that's the whole typoscript for the ce:
############################################
#### CTYPE:menu_distribution ####
############################################
tt_content.menu_distribution =< lib.contentElement
tt_content.menu_distribution {
templateName = MenuDistribution
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
as = menu
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
20 {
references.fieldName = teaser_image
as = teaserImage
}
}
}
}
stdWrap {
editIcons = tt_content: header [header_layout], pages
editIcons {
iconTitle.data = LLL:EXT:fluid_styled_content/Resources/Private/Language/FrontendEditing.xlf:editIcon.menu
}
}
}
In the template for the ce the variable menu contains nothing, if a page of type shortcut is selected.
TCA:
'pages' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.startingpoint',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => 3,
'maxitems' => 1,
'minitems' => 1
]
],
Sure, your shortcut is visible in menus?
The FSCs CE "Menu -> Subpages" (CType 'menu_pages') does nearly the same:
# Menu of subpages of selected pages:
# ...
#
# CType: menu_subpages
tt_content.menu_subpages =< lib.contentElement
tt_content.menu_subpages {
templateName = MenuSubpages
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
}
}
And in a test (TYPO3 v10), this CE shows me standard-pages and shortcuts.
Maybe, you are confusing "Shortcut" and "Mountpoint"...
Example
Selecting "Page 2" in the pages field of Contentelement "Subpages" (CType menu_subpages) is showing:
Page 2.1
Page 2.2
Selecting "Page 4" (which is of type "Shortcut" and pointing to "Page 2") is showing its own subpages:
Page 4.1
Selecting "Page 5" (which is of type "Mountpoint" and mounting "Page 2") is showing the subpages of the mounted page:
Page 2.1
Page 2.2

typo3 language chooser issues after choosing new language

Hi in my typo3 8 website I've added a language chooser. Choosing a language works fine, content switches from german to english it works fine content switches properly.
Issue is when I click a link in english version it always falls back to the german link because /en/ is missing in the Link URL
URL in the Browser looks good the en is there, but in the navigation the URL to an page does not conatin en
I use Typo3 8 and realURL
Typoscript:
config {
sys_language_uid = 0
language = de
locale_all = de_DE.UTF-8
htmlTag_langKey = de
}
config.tx_realurl_enable = 1
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en_US.UTF-8
htmlTag_langKey = en
}
[global]
temp.langMenu = HMENU
temp.langMenu.special = language
temp.langMenu.special.value = 0,1
temp.langMenu.1 = GMENU
temp.langMenu.1.NO {
XY = [5.w]+4, [5.h]+4
transparentColor = #17353e
backColor = #17353e
5 = IMAGE
5.file = fileadmin/design/images/flag_de.gif || fileadmin/design/images/flag_en.gif
}
temp.langMenu.1.ACT < lib.langMenu.1.NO
temp.langMenu.1.USERDEF1 < lib.langMenu.1.NO
temp.langMenu.1.USERDEF1 = 1
temp.langMenu.1.USERDEF1.5.file = fileadmin/design/images/flag_de.gif || fileadmin/design/images/flag_en.gif
temp.langMenu.1.USERDEF1.noLink = 1
RealURL Config:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'_DEFAULT' =>
array (
'init' =>
array (
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
'firstHitPathCache' => 1,
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
'preVars' =>
array (
0 =>
array (
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'en' => '1',
),
'valueDefault' => 'de',
# 'noMatch' => 'bypass',
),
),
),
);
What is my fail in this case?
Thanks in Advance.
You need to add config.linkVars = L(0-1) to your Typoscript config. This will tell the TYPO3 system to pass this link parameter to each generated url.
Please note that this configuration will only apply to internal links generated by the TYPO3 system itself: For example in menues or when you link another page in the RTE. Absolutely placed links will not be affected by this configuration.
The docs: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#linkvars

TYPO3: RealURL Language Switch for Extbase Extension

I have set up a single-domain website with different languages and configured RealURL.
On one page, there is a FE plugin with list and show actions. The links from the list to the show action are rendered correctly, for example:
en/press.html -> en/press/release1.html
en/press.html -> en/press/release2.html
Clicking on one of the links surfaces the detail page - so far, so good. Everything works as expected.
However, the language switch returns the following links (on the detail page):
en/press.html
de/presse.html
The links, of course, should read as follows:
en/press/release1.html
de/presse/aussendung1.html
Also, the breadcrumb menu does not show the detail page; it reads Home > Press, regardless of whether I'm on the list or show action.
Language Nav
temp.langNav = COA
temp.langNav {
10 = HMENU
10 {
special = language
special.value = 0,1,2,3,4,5,6,7,8
special.normalWhenNoLanguage = 0
wrap = <ul class="lang-sel__list">|</ul>
1 = TMENU
1 {
noBlur = 1
NO = 1
NO {
allWrap = <li class="lang-sel__item">|</li>
ATagParams = class="lang-sel__link"
stdWrap.setCurrent = English || Deutsch || Русский || Česky || Polski || Français || Română || Hrvatski || Slovenčina
stdWrap.current = 1
}
USERDEF1 = 1
USERDEF1 {
doNotLinkIt = 1
stdWrap.cObject = TEXT
stdWrap.cObject.value =
}
}
}
}
temp.selectedLang = TEXT
temp.selectedLang.value < config.language
Breadcrumb Nav
temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
wrap = |
1 = TMENU
1.noBlur = 1
1.CUR = 1
1.wrap = |
1.NO {
stdWrap.field = title
ATagParams = class="main-header__breadcrumb-link"
ATagTitle.field = nav_title // title
linkWrap = <li class="main-header__breadcrumb-item">|</li>
}
1.CUR {
stdWrap.field = title
linkWrap = <li class="main-header__breadcrumb-item">|</li>
doNotLinkIt = 1
}
}
}
RealURL Config
$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'init' => array(
'enableCHashCache' => 1,
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1,
'postVarSet_failureMode' => '',
),
'redirects' => array(),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'en' => 0,
'de' => 1,
'ru' => 2,
'cz' => 3,
'pl' => 4,
'fr' => 5,
'ro' => 6,
'hr' => 7,
'sk' => 8
),
'valueDefault' => 'en',
),
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
'firstHitPathCache' => 1,
),
'fixedPostVars' => array(
'_DEFAULT' => array(
array(
'GETvar' => 'press',
'lookUpTable' => array(
'table' => 'tx_myext_domain_model_press',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
),
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
)
)
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 1
),
),
);
You need to tell TYPO3 to keep the parameters.
This is done by configuring addQueryString in the HMENU ConentObject.
Your example would be extended by:
temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
1 {
NO {
addQueryString.exclude = L,cHash
}
}
}
}
For further information check the documentation:
docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.html and docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
And the solution above can be found on forge: https://forge.typo3.org/issues/16466#note-3

Typo3 sr_language_menu dropdown not working

I have installed and configured sr_language_menu(with real_url) in Typo3 6.2.
1.The translation is working, if I use links
But If I use Drop down list the redirection is not happening instead it contains some query string like this
/?tx_srlanguagemenu_languagemenu[__referrer][%40extension]=SrLanguageMenu&tx_srlanguagemenu_languagemenu[__referrer][%40controller]=Menu&tx_srlanguagemenu_languagemenu[__referrer][%40action]=index&tx_srlanguagemenu_languagemenu[__referrer][arguments]=YTowOnt9d9666863629331a07b703f260fec14a2665cc267&tx_srlanguagemenu_languagemenu[__trustedProperties]=a%3A0%3A{}cb8407c7c1f13f96cdceecffd389e5c5a2e8d31c&tx_srlanguagemenu_languagemenu[uri]=de%2Fzuhause%2F
How to hide non translated languages in drop down works fine in links but not working in dropdown(I use ShowInactive=0 in typoscript)
I used the following typoscript to hadle languages
lib.language = HMENU
lib.language {
special = language
special.value = 0,1
1 = TMENU
1 {
wrap =
class="dropdown-toggle" href="#">Language
class="dropdown-menu">|
noBlur = 1
NO {
linkWrap =
|
||
|
stdWrap.override = Nederlands || English
doNotLinkIt = 1
stdWrap.typolink.parameter.data = page:uid
stdWrap.typolink.additionalParams = &L=0 || &L=1
stdWrap.typolink.addQueryString = 1
stdWrap.typolink.addQueryString.exclude = L,id,cHash,no_cache
stdWrap.typolink.addQueryString.method = GET
stdWrap.typolink.useCacheHash = 1
stdWrap.typolink.no_cache = 0
stdWrap.typolink.title = Nederlands || English
}
ACT < .NO
ACT = 1
ACT {
linkWrap =
|
||
class="en_lang active">|
}
}
}
In your custom typo3conf/realurl_conf.php you need to set the languages
according to the id they have
array(
'GETvar' => 'L',
'valueMap' => array(
// id's need to line up with Website Language Ids in TYPO3
// 'nederlands' => '0',
'' => '0',
// 'english' => '1',
'en' => '1',
),
'noMatch' => 'bypass',
)