TYPO3 meta description - Text crop - typo3

here is the normal typoscript code for the Example like the Description:
page {
meta {
description = TEXT
description {
field = og_description // description
crop = 160| |1
}
}
}
How can i add a crop for the description Text?
Thanks all

With activated EXT:seo the tags are first set by PHP and after that, the TypoScript config is handled. The TypoScript configuration does not replace existing tags by default. So tags that have been set via PHP will not be overwritten.
If you'd like to change this default behavior, you have to use replace in TypoScript configuration (-> "MetaTag API > TypoScript and PHP":
page.meta {
description = TEXT
description.value = Override the pages description
description.replace = 1
}

As Julian mentioned: if you want to modify an existing meta tag definition you need to use replace (even if you only modify the existing definition)
If you only want to crop the existing text your code should be:
page {
meta {
description {
crop = 160| |1
replace = 1
}
}
}
If you also want to change the fields you could use
(my default is description.field = description):
page {
meta {
description {
field = og_description // description
crop = 160| |1
replace = 1
}
}
}
But don't use: description = TEXT as this will set the value TEXT to the meta tag

Related

Typo3 Content Elements missing in wizard

I have some content elements in a site package which I want to show up in the content element wizard as explained here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/ContentElementsWizard.html
Basically I have done the same as shown in the section "Create a new tab"
Configuration\TsConfig\Page\ContentElement\All.tsconfig is looking like this:
mod.wizards.newContentElement.wizardItems.mci.header = MCI
mod.wizards.newContentElement.wizardItems.mci {
elements {
mci_home_banner {
iconIdentifier = home-banner
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
mci_home_banner_element {
iconIdentifier = home-banner-element
title = Home Banner Element
description = Element im Starseitenbanner
tt_content_defValues.CType = mci_home_banner_element
}
}
show := addToList(mci_home_banner, mci_home_banner_element)
}
I reduced the code to just 2 elements. They are not shown at all, but are available over the dropdown, so I can switch to one of them after choosing another element.
This didn't work when created in 9.5 and still does not work after switching to version 11.5.10
What am I missing?
#user414873 Did you try to add your custom elements to the "common" tab instead of your new one "mci"?
And did you try to use an existing icon identifier (e.g. "content-image" or an other one - see https://typo3.github.io/TYPO3.Icons/)? Just to make sure that there is no problem with your custom icons that prevents the elements from being displayed.
Does this minimal example work for you:
mod.wizards.newContentElement.wizardItems.common {
elements {
mci_home_banner {
iconIdentifier = content-image
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
}
show := addToList(mci_home_banner)
}
And I would doubt this:
I guess otherwise the content elements wouldn't be available at all.
I suggest you check it's correctly included by using the "Info" module in your TYPO3 main menu. Then select the page where the content element should be included and switch the dropdown on top of the content area to "View TSconfig fields content". Now you can search for "wizards" and check if your element is included.

Is it possible to reorganize the default CEs in another Groups?

I would like to group several default typo3 CE into one group.
Is it possible?
The New Content Element Wizard can be changed with Page TSconfig. For example if you want the content element type html in the first tab, you can do the following:
mod.wizards.newContentElement.wizardItems.common {
elements {
html < mod.wizards.newContentElement.wizardItems.special.elements.html
}
show := addToList(html)
}
You can add a tab and fill it with an existing element like this:
mod.wizards.newContentElement.wizardItems.myTab {
header = My tab
elements {
html < mod.wizards.newContentElement.wizardItems.special.elements.html
}
show = html
}
To remove the existing type from its original tab, add:
mod.wizards.newContentElement.wizardItems.special.show := removeFromList(html)
More on this you can find here: https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/Mod.html#newcontentelement-wizarditems

Kentico Form Aria-Label

Is it possible to add aria labels to a Kentico form. I am adding the forms to my pages using the online form widget and I would like to add aria labels to each section to help make my site more ADA compliant.
I don't see the option by default in Kentico. It's a good request though. What you would need to do is to create your own form control that has the property.
https://docs.kentico.com/k10/custom-development/developing-form-controls
What you would look to do is clone the Textbox, add a property called "AriaLabel" to the form control's properties, then add this to the new code file for the textbox
In Properties region:
public string AriaLabel
{
get
{
return ValidationHelper.GetString(GetValue("AriaLabel"), "");
}
set
{
if (txtValue.Attributes["AriaLabel"] != null)
{
txtValue.Attributes["AriaLabel"] = ValidationHelper.GetString(GetValue("AriaLabel"), "");
}
else
{
txtValue.Attributes.Add("AriaLabel", ValidationHelper.GetString(GetValue("AriaLabel"), ""));
}
}
}
In Page_Load at bottom:
if (txtValue.Attributes["AriaLabel"] != null)
{
txtValue.Attributes["AriaLabel"] = AriaLabel;
}
else
{
txtValue.Attributes.Add("AriaLabel", AriaLabel);
}
If you will utilize label attribute for a field it will generate label tag for it in the HTML layout which will be accessibility compliant. Will that solve your purpose or are you looking specifically for aria-label tag only?

Setting the page title in TYPO3

I have the below code and which makes the page title more seo friendly. However I am running into the below problems.
config.noPageTitle = 1
page.headerData {
100 = TEXT
100 {
field = description
noTrimWrap = noTrimWrap = |<title>| - Example Site</title>|
}
}
If I have the field = title it displays tha page title field, however on the news single page it doesn't work as it displays the name of the page rather than the title of the aritle.
If I have the field = description the news single defaults to the article title however if I haven't put a description on one of my pages then it displays
<title> - Example Site</title>
Is there away to do if description = '' show title (if it is not a news article)?
Or is there another way I should be approaching this?
There are many samples and snippets for using tt_news title as page title.
Check for an instance this one: http://blog.chandanweb.com/typo3/display-news-title-as-page-title-in-tt_news-detail-view

tt_news default image in single view

In tt_news, how can I display a default image when there are no images associated with the news? I tried
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject = IMAGE
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject {
wrap =
file = fileadmin/images/image.jpg
}
but it doesn't display the image.
It should work with this:
plugin.tt_news.displaySingle.image.noImage_stdWrap {
cObject = IMAGE
cObject {
file = fileadmin/news-image-default.jpg
wrap =
}
}
i guess there is a dot between "displaySingle" and "image" missing?
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject = IMAGE
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject {
file = fileadmin/images/image.jpg
}
This code works for me. Path to file must be correct and image file must exists otherwise Typo don't display anything.
plugin.tt_news.displaySingle.image.noImage_stdWrap {
cObject = IMAGE
cObject {
file = fileadmin/tt_news/default_image.jpg
wrap = |
}
}