Automatic functionality for records¶
What does the automatic functionality do?¶
By using the automatic functionality the following will be added to your records:
- Backend:
- Fields of the core SEO extension:
SEO title
Robots: Index this page, Follow this page
Opengraph fields: Title, Description, Image
Twitter fields: Title, Description, Image, Card
Canonical link
Sitemap: Change frequency, Priority
- Functionality of Yoast SEO:
Snippet preview
Title and Description progress bar
Readability Analysis
SEO Analysis
Focus keyword
Advanced robots: Image index, Archive, Snippet
- Frontend:
- Metatag tags:
Description
Opengraph
Twitter
Robots
Canonical generation
Page title based on SEO Title and Title field
Configuration for a record¶
To get all the functionality mentioned above you only have to set the table
name and the GET parameters on which it responds to. This should be placed
in a file within Configuration/TCA/Overrides
of your extension
(f.e. sitepackage):
<?php
\YoastSeoForTypo3\YoastSeo\Utility\RecordUtility::configureForRecord('tx_extension_record')
->setGetParameters([
['tx_extension_pi1', 'record']
]);
This will automatically set the TCA, Database fields and activate the frontend functionality.
Configuration options¶
The method configureRecord
returns an object which has the following
methods:
setGetParameters¶
- Datatype
array
- Default
none
- Description
The GET parameters on where the frontend functionality should be activated. This should be a multidimensional array, which gives you the possibility to react to multiple situations.
Example
->setGetParameters([
['tx_extension_pi1', 'record'],
['tx_extension_pi1', 'record_preview']
])
setDefaultSeoFields¶
- Datatype
boolean
- Default
true
- Description
This will define if the default fields from EXT:seo should be added.
setYoastSeoFields¶
- Datatype
boolean
- Default
true
- Description
This will define if the fields from Yoast SEO should be added.
setSitemapFields¶
- Datatype
boolean
- Default
true
- Description
This will define if the fields "Change frequency" and "Priority" for Sitemap should be added.
setTypes¶
- Datatype
string
- Default
empty (all types)
- Description
Defines on which types of the record the fields should be added.
setTitleField¶
- Datatype
string
- Default
title
- Description
Sets the title field to another column.
setDescriptionField¶
- Datatype
string
- Default
description
- Description
Sets the description field to another column.
setAddDescriptionField¶
- Datatype
boolean
- Default
false
- Description
Adds the description column to both TCA and database (in case there's none already).
setFieldsPosition¶
- Datatype
string
- Default
after:title
- Description
Sets the position of the TCA fields.
setOverrideTca¶
- Datatype
array
- Default
none
- Description
Override TCA of the complete table. This can be useful if you want to change something of the TCA of the EXT:seo or Yoast SEO fields. This is needed because the automatic TCA generation is executed after all generated TCA, so trying to add this to one of the
Overrides
files will not take effect.
Example
->setOverrideTca([
'columns' => [
'seo_title' => [
'config' => [
'max' => 100
]
]
]
])
setGeneratePageTitle¶
- Datatype
boolean
- Default
true
- Description
This will enable/disable the functionality of the Page Title Provider in the frontend.
setGenerateMetaTags¶
- Datatype
boolean
- Default
true
- Description
This will enable/disable the rendering of the metatags in the frontend (in case you want to this yourself). This will not deactivate the canonical tag.
setGenerateRobotsTag¶
- Datatype
boolean
- Default
true
- Description
This will enable/disable the rendering of the robots metatag in the frontend (in case you always want the robot settings from the page it's displayed on).
Example with EXT:news¶
EXT:news has his own sitemap fields and has multiple GET parameters to respond to. The basic configuration can be:
\YoastSeoForTypo3\YoastSeo\Utility\RecordUtility::configureForRecord('tx_news_domain_model_news')
->setGetParameters([
['tx_news_pi1', 'news'],
['tx_news_pi1', 'news_preview']
])
->setSitemapFields(false)
->setFieldsPosition('after:bodytext');
Note
EXT:news provides an own Page Title Provider, if you want to use the
Page Title Provider of Yoast SEO you can unset the one from EXT:news
with typoscript: config.pageTitleProviders.news >
Adding PageTsconfig¶
Make sure to add the needed PageTsconfig mentioned in Other Plugins