Initial commit - Typo3 11.5.41

This commit is contained in:
Matteo Gallo
2026-07-03 17:53:31 +02:00
commit 5ca4743197
6811 changed files with 568848 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
.. include:: /Includes.rst.txt
.. _limitCE:
======================
Limit content elements
======================
If you want to limit the available content element types for news records, you have two options to configure that with Page TSConfig:
1. ``TCEFORM`` ::
TCEFORM.tt_content.CType.removeItems = html,bullets,div,menu_subpages
2. Backend Layout settings: ::
mod.web_layout.BackendLayouts.1.config.backend_layout.rows.1.columns.1.allowed = textmedia,textpic
TCAdefaults.tt_content.CType = textmedia
With the first line you change the allowed CTypes for the backend layout that applies to your news sysfolder.
The second line sets the default CType to prevent an error with e.g. ``INVALID VALUE ("text")``
.. Hint::
Regardless which option you choose, you need to wrap the TSConfig code with a TypoScript condition to limit the restriction to the sysfolder(s) where your news records reside, e.g with ``[123 in tree.rootLineIds]``
.. Hint::
Option 2 has the advantage, that if you want to allow only a very small number of content element types, you don't need to remove explicitly every CType. It's rather a whitelist approach.

View File

@@ -0,0 +1,183 @@
FlexForm
.. include:: /Includes.rst.txt
.. _breadcrumb:
===============
Breadcrumb menu
===============
There are currently two suggested ways to make a breadcrumb menu containing
the detail page of the current news: Based on data processing and Fluid template
and based on pure TypoScript. Use the first method if you have no breadcrumb yet
or your breadcrumb is already based on data processors. Use the second if
your breadcrumb is already based on TypoScript and you do not wish to change it
for now.
.. _breadcrumbFluid:
Breadcrumb based on data processing and Fluid
=============================================
.. versionadded:: 7.2.0
With version 7.2 a new data processor, :php:`AddNewsToMenuProcessor` has
been added which is useful for detail pages to add the news record as
fake menu entry.
To use the data processor :php:`AddNewsToMenuProcessor` add the following
TypoScript to the setup section in your site package extension. We assume
here that your main :typoscript:`FLUIDTEMPLATE` can be found in
:typoscript:`page.10`.
.. code-block:: typoscript
page.10 = FLUIDTEMPLATE
page.10 {
# [...] template settings
dataProcessing {
# [...] Other data processors
50 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
50 {
as = breadcrumbMenu
special = rootline
}
60 = GeorgRinger\News\DataProcessing\AddNewsToMenuProcessor
60.menus = breadcrumbMenu
}
}
The property :typoscript:`menus` of the :php:`AddNewsToMenuProcessor` must
contain the key of the :php:`MenuProcessor` containing your breadcrumb. If you
You can use more then one menu here by supplying several keys as comma-separated
list. For example: :typoscript:`60.menus = breadcrumbMenu,myOtherBreadcrumb`.
The data array containing your breadcrumb will now contain an additional entry
if you are on a news detail page. You can debug this data with the following
Fluid snippet:
.. code-block:: html
<f:debug>{breadcrumbMenu}</f:debug>
The array will then contain something like that:
.. code-block:: none
array(4 items)
0 => array(7 items)
1 => array(7 items)
2 => array(7 items)
data => array(84 items)
title => 'All News' (17 chars)
link => '/portal/news/' (34 chars)
target => '' (0 chars)
active => 1 (integer)
current => 0 (integer)
spacer => 0 (integer)
3 => array(6 items)
data => array(87 items)
title => 'Test news' (13 chars)
active => 1 (integer)
current => 1 (integer)
link => 'https://my-page.ddev.site/portal/news/articel/test-news' (101 chars)
isNews => TRUE
You can use code like the following in your sites Fluid template.
.. code-block:: html
<div class="container">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<f:for each="{breadcrumbMenu}" as="item" iteration="iterator">
<li class="breadcrumb-item ">
<a href="{item.link}" title="{item.title}">
<f:if condition="{item.isNews}"><i class="fas fa-newspaper"></i></f:if>
{item.title}
</a>
</li>
</f:for>
</ol>
</nav>
</div>
The result (using Bootstrap 5 and Fontawesome 5 Free) could use like this:
.. figure:: /Images/Frontend/Breadcrumb.png
:class: with-shadow
A breadcrumb containing the current news record.
.. hint::
I you are displaying the news on a single page that should not be displayed
without a valid news record, unset the flag :guilabel:`Page enabled in menus`
in the single pages page properties. This way the page alone does not appear
in the breadcrumb.
See also chapter :ref:`AddNewsToMenuProcessor <dataProcessing_AddNewsToMenuProcessor>`.
.. _breadcrumbTypoScript:
Breadcrumb based on TypoScript (legacy)
=======================================
If you already have a breadcrumb menu based on TypoScript in your project,
you can continue to use it and add the news record to it.
.. code-block:: typoscript
lib.navigation_breadcrumb = COA
lib.navigation_breadcrumb {
stdWrap.wrap = <ul class="breadcrumb">|</ul>
10 = HMENU
10 {
special = rootline
#special.range = 1
1 = TMENU
1 {
NO = 1
NO {
wrapItemAndSub = <li>|</li>
ATagTitle.field = subtitle // title
stdWrap.htmlSpecialChars = 1
}
CUR <.NO
CUR {
wrapItemAndSub = <li class="active">|</li>
doNotLinkIt = 1
}
}
}
# Add news title if on single view
20 = RECORDS
20 {
stdWrap.if.isTrue.data = GP:tx_news_pi1|news
dontCheckPid = 1
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
}
stdWrap.wrap = <li>|</li>
stdWrap.required = 1
}
}
The relevant part starts with :typoscript:`20 = RECORDS` as this cObject
renders the title of the news article.
.. Important::
Never forget the :typoscript:`source.intval = 1` to avoid SQL injections
and the :typoscript:`htmlSpecialChars = 1` to avoid Cross-Site Scripting.
See :ref:`security in TypoScript in TYPO3 Explained
<t3coreapi:security-typoscript>`.

View File

@@ -0,0 +1,115 @@
.. include:: /Includes.rst.txt
.. _cacheClearing:
==============
Cache clearing
==============
.. _cacheClearing-changed-records:
Clearing the cache after changing news records
==============================================
News has a built-in mechanism that takes care of clearing the cache after
manipulation of News records.
When a list or detail view is rendered on a page, a cache tag in format
:php:`tx_news_pid_PID` (where PID is the uid of the news storage folder) is
added. Each time a news record is edited, deleted or created, this cache entry
is flushed. No additional cache configuration is needed if only the News
plugins are used.
If you use other ways of displaying news records (e.g. an RSS feed created
by TypoScript on a page without a News plugin), the cache is not flushed
automatically.
This can be done automatically by using this command in the PageTsConfig: :
.. code-block:: typoscript
:caption: page TSconfig
TCEMAIN.clearCacheCmd = 123,456,789
The code needs to be added to the sys folder where the news records are edited.
Change the example page ids to the ones which should be cleared, e.g. a page
with an RSS feed. You can use:
.. code-block:: typoscript
:caption: page TSconfig
TCEMAIN.clearCacheCmd = pages
to clear the complete caches as well:
.. code-block:: typoscript
:caption: page TSconfig
TCEMAIN.clearCacheCmd = cacheTag:tx_news
to clear all caches of pages on which the news plugins are used but beware of
performance issues when news records are edited often.
.. hint::
The mentioned TCEMAIN settings are part of the TYPO3 Core and can be used
therefore not only for the news extension. Read more about the
:ref:`clearCacheCmd in the TSconfig reference <t3tsconfig:pagetcemain-clearcachecmd>`.
.. _cacheClearing-publishing-date:
Cache lifetime and auto publishing (by setting start date)
==========================================================
By default the cache of TYPO3 pages is invalidated every 24 hours. If you set
a specific date and time for the news record to be published in the tab
:guilabel:`Access`:
.. include:: /Images/ManualScreenshots/NewsRecordAccess.rst.txt
The news will be published next time the cache is deleted which is usual after
midnight.
When you are using the :guilabel:`Publish Date` field you can use the following
TypoScript setup configuration: :ref:`config.cache <t3tsref:setup-config-cache>`
Let us assume you have a news plugin on page 42 and store your news records in a
sysfolder with the uid 27 then the following setting will take the publish date
of your news records into account when calculating the time when the cache
should expire:
.. code-block:: typoscript
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.42 = tx_news_domain_model_news:27
If there is more then one page containing a news plugin that might display the
news you have to make a setting for each page:
.. code-block:: typoscript
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache {
42 = tx_news_domain_model_news:27
43 = tx_news_domain_model_news:27
365 = tx_news_domain_model_news:27
}
If you use a news plugin on every page it is also possible to define the
cache clearing for all pages:
.. code-block:: typoscript
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.all = tx_news_domain_model_news:27
You can also define serveral tables for one page, for example to include
categories:
.. code-block:: typoscript
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.42 = tx_news_domain_model_news:27,sys_category:26

View File

@@ -0,0 +1,72 @@
.. include:: /Includes.rst.txt
.. _hideDetailPage:
=======================
Hide detail page in URL
=======================
This tutorials covers the use case of having the following page structure:
.. code-block:: none
.
└── Root
├── Home
└── Blog <= news
The URL of a news record should howeverb be `domain.tld/blog/news-record`.
The page *Blog* typically contains not only the news plugin with the list view
but also additional regular content elements which must **not** be rendered in the detail view.
The following TypoScript will make this possible:
.. code-block:: typoscript
# Override content rendering if the news record is requested
[traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
# typically having something like: page.10 = FLUIDTEMPLATE
# optional to use a custom page template
page.10.templateName = NewsDetail
lib.dynamicContent >
lib.dynamicContent = USER
lib.dynamicContent {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = detail
}
}
settings < plugin.tx_news.settings
settings {
# fully optional but can be used to react on it in
# the news templates
templateLayout = renderedByTs
}
}
[end]
The **page template** `NewsDetail.html` must contain the following code to
render the news detail view:
.. code-block:: html
<f:cObject typoscriptObjectPath="lib.dynamicContent" />
Some further explanations
^^^^^^^^^^^^^^^^^^^^^^^^^
* The TypoScript condition will only be true if a news record path is in the URL
* It overrides the used page template to be able to use a custom one
* It set the variable `lib.dynamicContent` to contain the rendered news detail view
* The dedicated page template can be fully adopted
* If needed, the News detail template can be adopted by either use a settings variable or by providing a custom view path.

View File

@@ -0,0 +1,206 @@
.. include:: /Includes.rst.txt
.. _icalendar:
==============
ICalendar feed
==============
Displaying an iCalendar feed is the same as a normal list view, just with a different template.
Therefore you won't need any different configuration to e.g. excluded categories or configure the single view page.
.. only:: html
.. contents::
:local:
:depth: 3
The template for the iCalendar feed can be found in the file Resources/Private/Templates/News/List.ical.
The "magic" which uses the List.ical template instead of the List.html is the following configuration:
.. code-block:: typoscript
plugin.tx_news.settings.format = ical
plugin.tx_news.settings.domain.data = getEnv:HTTP_HOST
plugin.tx_news.settings.useStdWrap = domain
iCalendar feed by TypoScript
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A very simple way to generate the iCalendar feed is using plain TypoScript. All you need is to use the given TypoScript and adopt it to your needs.
.. code-block:: typoscript
[globalVar = TSFE:type = 9819]
config {
disableAllHeaderCode = 1
xhtml_cleaning = none
admPanel = 0
metaCharset = utf-8
# For 7 LTS
additionalHeaders = Content-Type:text/calendar;charset=utf-8
# Since 8 LTS
additionalHeaders.10.header = Content-Type:text/calendar;charset=utf-8
disablePrefixComment = 1
linkVars >
}
pageNewsICalendar = PAGE
pageNewsICalendar {
typeNum = 9819
10 < tt_content.list.20.news_pi1
10 {
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
categories = 9
categoryConjunction = notor
limit = 30
detailPid = 25
startingpoint = 24
format = ical
domain.data = getEnv:HTTP_HOST
useStdWrap = domain
}
}
}
[global]
This example will show all news records which don't have the category with the uid 9 assigned and are saved on the page with uid 24.
The iCalendar feed itself can be found with the link **/?type=9819**.
iCalendar feeds by using a normal plugin
""""""""""""""""""""""""""""""""""""""""
Sometimes it is more convenient to generate the iCalendar feed using the normal plugin.
The biggest advantage is that the complete configuration can be done within the backend without touching TypoScript.
To create an ICalendar feed based on a plugin follow this steps:
#. Create a new page.
#. Add the news plugin and define the configuration you need. E.g. startingpoint, page with the single view, ...
#. Define a new TypoScript template and use a code like below. **Very
important** : Use :typoscript:`config.absRefPrefix = http://www.yourdomain.tld/` to
produce absolute urls for links and images!
.. code-block:: typoscript
page = PAGE
page.10 < styles.content.get
page.config {
# deactivate Standard-Header
disableAllHeaderCode = 1
# no xhtml tags
xhtml_cleaning = none
admPanel = 0
metaCharset = utf-8
# define charset
additionalHeaders = Content-Type:text/calendar;charset=utf-8
disablePrefixComment = 1
linkVars >
}
# set the format
plugin.tx_news.settings.format = ical
# set the domain for real unique uids
plugin.tx_news.settings.domain.data = getEnv:HTTP_HOST
plugin.tx_news.settings.useStdWrap = domain
# delete content wrap
tt_content.stdWrap >
**Important:** If your output still contains HTML code, please check your TypoScript
(especially from css\_styled\_content) as this HTML is produced there!
Automatic iCalendar feeds - based on plugins
""""""""""""""""""""""""""""""""""""""""""""
There are use cases where many different list views are needed and each list view should also get its own iCalendar feed **without any additional configuration**.
The TypoScript code looks like this.
.. code-block:: typoscript
[globalVar = TSFE:type = 9819]
lib.stdheader >
tt_content.stdWrap.innerWrap >
tt_content.stdWrap.wrap >
# get away <div class="feEditAdvanced-firstWrapper" ...> if your logged into the backend
styles.content.get.stdWrap >
pageNewsICalendar = PAGE
pageNewsICalendar.typeNum = 9819
pageNewsICalendar.10 < styles.content.get
pageNewsICalendar.10.select.where = colPos=0 AND list_type = "news_pi1"
pageNewsICalendar.10.select {
orderBy = sorting ASC
max = 1
}
config {
# deactivate Standard-Header
disableAllHeaderCode = 1
# no xhtml tags
xhtml_cleaning = none
admPanel = 0
metaCharset = utf-8
# you need an english locale to get correct rfc values for <lastBuildDate>, ...
locale_all = en_EN
# define charset
additionalHeaders = Content-Type:text/calendar;charset=utf-8
disablePrefixComment = 1
linkVars >
}
# set the format
plugin.tx_news.settings.format = ical
# set the domain for real unique uids
plugin.tx_news.settings.domain.data = getEnv:HTTP_HOST
plugin.tx_news.settings.useStdWrap = domain
# delete content wrap
tt_content.stdWrap >
[global]
**Some explanations**
The page object ``pageNewsICalendar`` will render only those content elements which are in colPos 0 and are a news plugin. Therefore all other content elements won't be rendered in the iCalendar feed.
Misc
^^^^
Add a link to the iCalendar feed in the list view
"""""""""""""""""""""""""""""""""""""""""""""""""
To be able to render a link in the header section of the normal page which points to the iCalendar feed you can use something like this in your List.html Fluid template.
.. code-block:: html
<n:headerData>
<link rel="alternate" type="text/calendar" title="iCalendar 2.0" href="{f:uri.page(additionalParams:{type:9819})}" />
</n:headerData>
Change the iCalendar feed link with routing
"""""""""""""""""""""""""""""""""""""""""""
If you want to rewrite the URL, use a configuration like this one. Read more
about :ref:`rewriting URLs for news <routing>`.
.. code-block:: yaml
routeEnhancers:
News:
PageTypeSuffix:
type: PageType
map:
'feed.xml': 9818
'calendar.ical': 9819
This will change the URL to :code:`/calendar.ical`.

View File

@@ -0,0 +1,188 @@
.. include:: /Includes.rst.txt
.. _tutorialsBestPractice:
=============
Best practice
=============
.. container:: row m-0 p-0
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`SEO <seo>`
.. container:: card-body
Optimize EXT:news for display in search engines.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`View Button <viewButton>`
.. container:: card-body
Display a :guilabel:`View` button on top of news records in the
backend.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`TSconfig code snippets <general_tsconfig_examples>`
.. container:: card-body
Code snippets to influence the behaviour of news record editing
in the backend and the news administration module.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Routing <routing>`
.. container:: card-body
Use routing to generate user readable urls to news, categories,
tags, paginized results etc
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Breadcrumb menu <breadcrumb>`
.. container:: card-body
Display the current news title in the breadcrumb
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`RSS <rss>`
.. container:: card-body
Provide a RSS feed promoting your news
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`ICalendar feed <icalendar>`
.. container:: card-body
Provide an iCalendar feed
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`LinkHandler <linkhandler>`
.. container:: card-body
Enable your editors to link to specific news from anywhere.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Limit content elements <limitCE>`
.. container:: card-body
Configure available content element types in news records.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Integrations with TypoScript <integrationTypoScript>`
.. container:: card-body
Configure available content element types in news records.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Cache clearing <cacheClearing>`
.. container:: card-body
Automatic cache clearing
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Predefine values <predefineValues>`
.. container:: card-body
Learn how to set default values, influence the choices of select
fields etc.
.. container:: col-12 col-md-6 pl-0 pr-3 py-3 m-0
.. container:: card px-0 h-100
.. rst-class:: card-header h3
.. rubric:: :ref:`Hide detail page <hideDetailPage>`
.. container:: card-body
Avoid the detail page in the url and reuse the list page.
.. toctree::
:maxdepth: 5
:titlesonly:
:hidden:
Seo/Index
PreviewOfRecord/Index
TsConfigExamples/Index
Routing/Index
BreadcrumbMenu
Rss/Index
Linkhandler/Index
AvailableContentElements/Index
IntegrationWithTypoScript/Index
HideDetailPage/Index
ClearCache/Index
PredefineFields/Index
ICalendar/Index

View File

@@ -0,0 +1,325 @@
.. include:: /Includes.rst.txt
.. highlight:: typoscript
.. _integrationTypoScript:
============================
Integrations with TypoScript
============================
This page gives you same examples which you can use for integrating EXT:news into a website.
.. only:: html
.. contents::
:local:
:depth: 1
Add news by TypoScript
^^^^^^^^^^^^^^^^^^^^^^
If EXT:news should be integrated by using TypoScript only, you can use this code snippet:
.. code-block:: typoscript
lib.news = USER
lib.news {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
//categories = 49
limit = 30
detailPid = 31
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 13
}
}
Now you can use the object lib.news.
List and detail on the same page using TypoScript
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the example of how to display list and detail view on the same page.
.. code-block:: typoscript
# Basic plugin settings
lib.news = USER
lib.news {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = Pi1
vendorName = GeorgRinger
extensionName = News
controller = News
settings =< plugin.tx_news.settings
persistence =< plugin.tx_news.persistence
view =< plugin.tx_news.view
}
Configure list and detail actions:
.. code-block:: typoscript
lib.news_list < lib.news
lib.news_list {
action = list
switchableControllerActions.News.1 = list
}
lib.news_detail < lib.news
lib.news_detail {
action = detail
switchableControllerActions.News.1 = detail
}
Insert configured objects to wherever you want to use them, depending on the GET parameter of detail view:
.. code-block:: typoscript
[traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
page.10.marks.content < lib.news_detail
[else]
page.10.marks.content < lib.news_list
[end]
Add news to breadcrumb menu
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This example has been moved to the
:ref:`Tutorial: Breadcrumb menus <breadcrumbTypoScript>`.
Add HTML to the header part in the detail view.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There might be a use case where you need to add specific code to the header part when the detail view is rendered.
There are some possible ways to go.
Plain TypoScript
""""""""""""""""
You could use a code like the following one to render e.g. the title of a news article inside a title-tag.
.. code-block:: typoscript
[globalVar = TSFE:id = NEWS-DETAIL-PAGE-ID]
config.noPageTitle = 2
temp.newsTitle = RECORDS
temp.newsTitle {
dontCheckPid = 1
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
}
wrap = <title>|</title>
}
page.headerData.1 >
page.headerData.1 < temp.newsTitle
[global]
If you want to show the categories of a news record, you can use the following code:
.. code-block:: typoscript
lib.categoryTitle = CONTENT
lib.categoryTitle {
if.isTrue.data = GP:tx_news_pi1|news
table = tx_news_domain_model_news
select {
uidInList.data = GP:tx_news_pi1|news
pidInList = 123
join = sys_category_record_mm ON tx_news_domain_model_news.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
orderBy = sys_category.sorting
max = 1
}
renderObj = TEXT
renderObj {
field = title
htmlSpecialChars = 1
}
}
Usage of a ViewHelper
"""""""""""""""""""""
Use a viewHelper of EXT:news to write any code into the header part. The code could look like this
.. code-block:: xml
<n:headerData><script>var newsId = {newsItem.uid};</n:headerData>
If you want to set the title tag, you can use a specific viewHelper:
.. code-block:: xml
<n:titleTag>{newsItem.title}</n:titleTag>
Fallback in Detail view if no news found
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the detail view is called without a news uid given, an error is thrown (depending on the setting **settings.errorHandling**).
If the desired behaviour is to show a different news record this can be set in the plugin with the field "singleNews".
The drawback would be that the alternative news record would be always the same. If this should be kind of dynamic, take a
look at the given TypoScript snippet:
.. code-block:: typoscript
plugin.tx_news.settings {
overrideFlexformSettingsIfEmpty = singleNews,cropMaxCharacters,dateField,timeRestriction,orderBy,orderDirection,backPid,listPid,startingpoint
useStdWrap = singleNews
singleNews.stdWrap.cObject = CONTENT
singleNews.stdWrap.cObject {
table = tx_news_domain_model_news
select {
max = 1
orderBy = datetime desc
pidInList = 3
}
renderObj = TEXT
renderObj.field = uid
}
}
By using the field *useStdWrap* it is possible to call the full range of stdWrap on any setting. In this case the first news record
from the page with uid 3 is used as fallback.
Show news items with same category in Detail.html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you want to show in the detail action articles with the same category as the current one, you can use a snippet like this one:
Add this to the ``Detail.html`` which will pass the first category uid to the TypoScript object ``lib.tx_news.relatedByFirstCategory``.
.. code-block:: html
<f:if condition="{newsItem.firstCategory}">
<f:cObject typoscriptObjectPath="lib.tx_news.relatedByFirstCategory">{newsItem.firstCategory.uid}</f:cObject>
</f:if>
.. code-block:: typoscript
lib.tx_news.relatedByFirstCategory = USER
lib.tx_news.relatedByFirstCategory {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
relatedView = 1
detailPid = 31
useStdWrap := addToList(categories)
categories.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 78
}
}
Important is the line ``categories.current = 1`` which will set the category configuration.
Of course you need to adopt the snippet to your own needs, like setting the ``detailPid``, ``startingPoint``, ...
By defining a custom property like ``relatedView = 1`` you can differ in the ``List.html`` if it is called by this snippet or by a regular plugin.
Show news items with same tags in Detail.html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Similar to the example above it is also possible to render news records with the same tags as the current one.
.. code-block:: typoscript
lib.tx_news.relatedByTags = USER
lib.tx_news.relatedByTags {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
# custom tag to use in List.html
relatedView = 1
# limit number of news
limit = 6
# startingpoint = 1
useStdWrap := addToList(tags)
tags.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
excludeAlreadyDisplayedNews = 1
}
}
In your overridden Detail.html template place the following code after displaying detailed news.
.. code-block:: html
<f:if condition="{newsItem.tags}">
<f:cObject typoscriptObjectPath="lib.tx_news.relatedByTags">{newsItem.tags->v:iterator.extract(key:'uid')->v:iterator.implode(glue: ',')}</f:cObject>
</f:if>
The Fluid tags supply comma-separated list of tags' UIDs to the Typoscript code.
Either write custom ViewHelper or install vhs extension and add its namespace :html:`xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"` to the `Detail.html` template.
Show Category Menu with Typoscript
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: 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 = 11
}
}

View File

@@ -0,0 +1,77 @@
.. include:: /Includes.rst.txt
.. _linkhandler:
===========
LinkHandler
===========
**LinkHandler** is the synonym for making it possible for editors to create links to custom records.
Until 8 LTS a 3rd party extension has been required but since then it is integrated into the Core. Read at https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.6/Feature-79626-IntegrateRecordLinkHandler.html about the feature.
.. tip::
This tutorial is also valid for creating links to any other record.
Configuration for the backend
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PageTsConfig is used to configure the link browser in the backend.
.. code-block:: typoscript
# tx_news is an identifier, don't change it after links have been created
TCEMAIN.linkHandler.tx_news {
handler = TYPO3\CMS\Recordlist\LinkHandler\RecordLinkHandler
# A translatable label can be used with LLL:EXT:theme/locallang.xml:label
label = News
configuration {
table = tx_news_domain_model_news
# Default storage pid
storagePid = 123
# Hide the page tree by setting it to 1
hidePageTree = 0
}
scanAfter = page
}
Configuration for the frontend
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The links are now stored in the database with the syntax `<a href="t3://record?identifier=tx_news&amp;uid=456">A link</a>`.
By using TypoScript, the link is transformed into an actual link.
.. code-block:: typoscript
config.recordLinks.tx_news {
typolink {
# Detail page
parameter = 123
additionalParams.data = field:uid
additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
}
}
Dynamic target page from category field single_pid
""""""""""""""""""""""""""""""""""""""""""""""""""
if the detail page is provided by the category, the following code can be used to retrieve the target page:
.. code-block:: typoscript
config.recordLinks.tx_news {
typolink {
# Detail page
parameter.cObject = USER
parameter.cObject {
userFunc = GeorgRinger\News\Service\LinkHandlerTargetPageService->process
news.data = field:uid
# Page used if no detail page is set in the category
fallback = 123
}
additionalParams.data = field:uid
additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
}
}

View File

@@ -0,0 +1,111 @@
.. include:: /Includes.rst.txt
.. _predefineValues:
================
Predefine values
================
This section will show you how you can predefine values of fields in records in the TYPO3 backend using TSconfig.
Default values
^^^^^^^^^^^^^^
.. tip:: This is a feature of TYPO3 itself, so you can use this also for all other tables and fields.
If you want to use some default values, you can use this code inside the TSconfig (tab:Resources) of the folder containing the News records:
.. code-block:: typoscript
# Syntax is always TCAdefaults.<tablename>.<fieldname> = value
TCAdefaults {
tx_news_domain_model_news {
author = John Doe
categories = 9
}
}
Select fields
^^^^^^^^^^^^^
If you want to preselect a value from a select field, you need to set the value of the option field as value.
In this example the language with the uid 3 will be preselected:
.. code-block:: typoscript
TCAdefaults.tx_news_domain_model_news {
sys_language_uid = 3
}
If you want to remove an option from a select field you can take a look at this example which removes the
option "Images" from the media selection dropdown:
.. code-block:: typoscript
TCEFORM.tx_news_domain_model_media {
type.removeItems = 0
}
Author name & email
^^^^^^^^^^^^^^^^^^^
By using the following code in the PageTsConig, the fields `Author` and `Author Email` are prefilled with the name and email address of the current backend user
.. code-block:: typoscript
tx_news.predefine.author = 1
Archive date
^^^^^^^^^^^^
EXT:news allows you to use an improved syntax to predefine the archive date by using this Page TSconfig:
.. code-block:: typoscript
tx_news.predefine.archive = <value>
As value you can use anything which can be interpreted by the php function `strtotime <http://de2.php.net/manual/en/function.strtotime.php>`__.
For example:
- +1 day
- next Monday
- +1 week 2 days 4 hours
Add the characters counter below an input field
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you want to give a hint to editors so they know how many chars they can use for the Teaser field, you simply add this TSconfig to the folder:
.. code-block:: typoscript
TCEFORM.tx_news_domain_model_news.teaser.config.max = 200
Modify flexform values
^^^^^^^^^^^^^^^^^^^^^^
The flexform values can be modified by using TSconfig.
.. code-block:: typoscript
TCEFORM {
tt_content {
pi_flexform {
news_pi1 {
sDEF {
settings\.orderDirection.disabled = 1
settings\.orderBy.addItems {
teaser = teaser
}
}
}
}
}
}
.. attention::
The dot inside the field name must be escaped!
To identify the key of the tab (e.g. `sDEF`) and the field name (e.g. `settings.orderBy`)
look either in the source code while checking the flexforms or look into the configuration itself
which can be found at `EXT:news/Configuration/FlexForms/flexform_news.xml`.

View File

@@ -0,0 +1,47 @@
.. include:: /Includes.rst.txt
.. _viewButton:
===========
View button
===========
It is possible to activate the :guilabel:`View` Button for news records.
This button is displayed on the top of the edit record page:
.. figure:: /Images/ManualScreenshots/ViewButton.png
:class: with-shadow
The :guilabel:`View` button
Add the following page TSconfig to your root page. It is recommended to use
a site package extension, see
:doc:`Official Tutorial: Site Package <t3sitepackage:Index>` for this purpose.
.. code-block:: typoscript
TCEMAIN.preview {
tx_news_domain_model_news {
previewPageId = 123
useDefaultLanguageRecord = 0
fieldToParameterMap {
uid = tx_news_pi1[news_preview]
}
additionalGetParameters {
tx_news_pi1.controller = News
tx_news_pi1.action = detail
}
}
}
By using the given example, a link will be generated which leads to the
page with the id `123`.
If a news plugin is placed on this page, the news article will be shown.
.. hint::
This TSconfig configuration can be used to display any record with with any
kind of parameters. Read more about it in
:ref:`TSconfig Reference: TCEMAIN.preview <t3tsconfig:pagetcemain-preview>`.

View File

@@ -0,0 +1,16 @@
:orphan:
.. TODO: remove this section with the next major release of news
.. include:: /Includes.rst.txt
.. _realurl:
============================
Replace RealURL with routing
============================
The extension EXT:realurl is outdated. Use the build-in
:ref:`TYPO3 routing <routing>` to rewrite the urls instead. Read more about
:ref:`Migration from realurl to news with routing <migration_realurl_routing>`.

View File

@@ -0,0 +1,475 @@
.. include:: /Includes.rst.txt
.. _routing:
===========================
Use Routing to rewrite URLs
===========================
This section will show you how you can rewrite the URLs for news using
**Routing Enhancers and Aspects**. TYPO3 Explained has an capter
:ref:`Introduction to routing <t3coreapi:routing-introduction>` that you can read
if you are not familiar with the concept yet. You will no
longer need third party extensions like RealURL or CoolUri to rewrite and
beautify your URLs.
.. _how_to_rewrite_urls:
How to rewrite URLs with news parameters
----------------------------------------
On setting up your page you should already have created a **site configuration**.
You can do this in the backend module :guilabel:`Site Managements > Sites`.
Your site configuration will be stored in
:file:`/config/sites/<your_identifier>/config.yaml`. The following
configurations have to be applied to this file.
Any URL parameters can be rewritten with the Routing Enhancers and Aspects.
These are added manually in the :file:`config.yaml`:
#. Add a section :yaml:`routeEnhancers`, if one does not already exist.
#. Choose an unique identifier for your Routing Enhancer. It doesn't have
to match any extension key.
#. :yaml:`type`: For news, the Extbase Plugin Enhancer (:yaml:`Extbase`)
is used.
#. :yaml:`extension`: the extension key, converted to :code:`UpperCamelCase`.
#. :yaml:`plugin`: the plugin name of news is just *Pi1*.
#. After that you will configure individual routes and aspects depending on
your use case.
.. code-block:: yaml
:linenos:
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
# routes and aspects will follow here
.. tip::
If your routing doesn't work as expected, check the **indentation** of your
configuration blocks.
Proper indentation is crucial in YAML.
Using limitToPages
~~~~~~~~~~~~~~~~~~
It is recommended to limit :yaml:`routeEnhancers` to the pages where they are needed.
This will speed up performance for building page routes of all other pages.
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
:emphasize-lines: 4-7
routeEnhancers:
News:
type: Extbase
limitToPages:
- 8
- 10
- 11
extension: News
plugin: Pi1
# routes and aspects will follow here
Multiple routeEnhancers for news
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you use the news extension for different purposes on the same website
(for example news and events), you may want different URL paths for
them (for example */article/* and */event/*).
It is possible to configure more than one routing enhancer for the news plugin
on the same website.
Use :yaml:`limitToPages` to assign the appropriate configuration to the
desired pages.
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
:emphasize-lines: 2,11
routeEnhancers:
News:
type: Extbase
limitToPages:
- 8
- 10
- 11
extension: News
plugin: Pi1
# etc.
NewsEvents:
type: Extbase
limitToPages:
- 17
- 18
extension: News
plugin: Pi1
# etc.
About routes and aspects
~~~~~~~~~~~~~~~~~~~~~~~~
In a nutshell:
* :yaml:`routes` will extend an existing route (means: your domain and page
path) with arguments from GET parameters, like the following
controller/action pair of the news detail view.
* :yaml:`aspects` can be used to modify these arguments. You could for
example map the title (or better: the optimized path segment) of the
current news.
Different types of *Mappers* and *Modifiers* are available, depending on
the case.
1. URL of detail page without routing:
.. code-block:: none
https://www.example.com/news/detail?tx_news_pi1[action]=detail&tx_news_pi1[controller]=News&tx_news_pi1[news]=5&cHash=
2. URL of detail page with routes:
.. code-block:: none
https://www.example.com/news/detail/5?cHash=
3. URL of detail page with routes and aspects:
.. code-block:: none
https://www.example.com/news/detail/title-of-news-article
The following example will only provide routing for the detail view:
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
Please note the placeholder :code:`{news-title}`:
#. First, you assign the value of the news parameter (:code:`tx_news_pi1[news]`)
in :yaml:`_arguments`.
#. Next, in :yaml:`routePath` you add it to the existing route.
#. Last, you use :yaml:`aspects` to map the :code:`path_segment` of the
given argument.
Both routes and aspects are only available within the current Routing Enhancer.
The names of placeholders are freely selectable.
Common routeEnhancer configurations
-----------------------------------
Basic setup (including categories, tags and the RSS/Atom feed)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Prerequisites:**
The plugins for :guilabel:`List View` and :guilabel:`Detail View` are on
separate pages.
If you use the :guilabel:`Category Menu` or :guilabel:`Tag List` plugins to
filter news records, their titles (slugs) are used.
**Result:**
* Detail view: ``https://www.example.com/news/detail/the-news-title``
* Pagination: ``https://www.example.com/news/page-2``
* Category filter: ``https://www.example.com/news/my-category``
* Tag filter: ``https://www.example.com/news/my-tag``
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/'
_controller: 'News::list'
- routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: 'currentPage'
- routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
- routePath: '/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
- routePath: '/{tag-name}'
_controller: 'News::list'
_arguments:
tag-name: overwriteDemand/tags
defaultController: 'News::list'
defaults:
page: '0'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
page:
type: StaticRangeMapper
start: '1'
end: '100'
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
tag-name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: slug
PageTypeSuffix:
type: PageType
map:
'feed.xml': 9818
'calendar.ical': 9819
Localized pagination
~~~~~~~~~~~~~~~~~~~~
**Prerequisites:**
The website provides several frontend languages.
**Result:**
* English: ``https://www.example.com/news/page-2``
* Danish: ``https://www.example.com/da/news/side-2``
* German: ``https://www.example.com/de/news/seite-2``
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
:emphasize-lines: 21-27
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/{page-label}-{page}'
_controller: 'News::list'
_arguments: {'page': 'currentPage'}
defaultController: 'News::list'
defaults:
page: ''
requirements:
page: '\d+'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
page-label:
type: LocaleModifier
default: 'page'
localeMap:
- locale: 'da_DK.*'
value: 'side'
- locale: 'de_DE.*'
value: 'seite'
**Explanation:**
The :yaml:`LocaleModifier` aspect type will set a default value for the
English language.
You're then able to add as many :yaml:`localeMap` configurations as you
need for the page translations of your website.
The value of :yaml:`locale` refers to the value in your site configuration.
Human readable dates
~~~~~~~~~~~~~~~~~~~~
**Prerequisites:**
For :guilabel:`List View` with a :guilabel:`Date Menu` plugin, to filter
by date. Also includes configuration for the pagination.
**Result:**
* ``https://www.example.com/news/2018/march``
* ``https://www.example.com/news/2018/march/page-2``
.. code-block:: yaml
:caption: :file:`/config/sites/<your_identifier>/config.yaml`
:linenos:
routeEnhancers:
DateMenu:
type: Extbase
extension: News
plugin: Pi1
routes:
# Pagination:
- routePath: '/'
_controller: 'News::list'
- routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: 'currentPage'
requirements:
page: '\d+'
- routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
# Date year:
- routePath: '/{date-year}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: 'currentPage'
requirements:
date-year: '\d+'
# Date year + pagination:
- routePath: '/{date-year}/page-{page}'
_controller: 'News::list'
_arguments:
date-year: 'overwriteDemand/year'
page: 'currentPage'
requirements:
date-year: '\d+'
page: '\d+'
# Date year/month:
- routePath: '/{date-year}/{date-month}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: 'currentPage'
requirements:
date-month: '\d+'
date-year: '\d+'
# Date year/month + pagination:
- routePath: '/{date-year}/{date-month}/page-{page}'
_controller: 'News::list'
_arguments:
date-month: 'overwriteDemand/month'
date-year: 'overwriteDemand/year'
page: 'currentPage'
requirements:
date-month: '\d+'
date-year: '\d+'
page: '\d+'
defaultController: 'News::list'
defaults:
page: '0'
date-month: ''
date-year: ''
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
page:
type: StaticRangeMapper
start: '1'
end: '25'
date-month:
type: StaticValueMapper
map:
january: '01'
february: '02'
march: '03'
april: '04'
may: '05'
june: '06'
july: '07'
august: '08'
september: '09'
october: '10'
november: '11'
december: '12'
date-year:
type: StaticRangeMapper
start: '2000'
end: '2030'
**Explanation:**
You will need a new :yaml:`routePath` for every possible combination of
arguments (pagination, month with/without pagination, ...).
**Potential errors:**
If you want :code:`2018/march` but get :code:`2018/3` instead, compare your
:yaml:`StaticValueMapper` for months with your date arguments.
Are you using different date formats (with/without leading zeros)?
You can either remove the leading zero in your :yaml:`aspects` or adapt the
TypoScript setting:
.. code-block:: typoscript
:caption: TypoScript setup
:linenos:
:emphasize-lines: 6
plugin.tx_news.settings.link {
hrDate = 1
hrDate {
day = j
// 'n' for 1 through 12. 'm' for 01 through 12.
month = m
year = Y
}
}
You can configure each argument (day/month/year) separately by using the
configuration of PHP function `date <http://www.php.net/date>`__.
.. warning::
| **Oops, an error occurred!**
| Possible range of all mappers is larger than 10000 items
Using the :yaml:`StaticRangeMapper` is strictly limited to 1000 items per
a single range and 10000 items per routing enhancer.
That means you'll have to multiply all possible combinations in a routing
enhancer, for example:
12 months × 30 years *(2000-2030)* × 25 pages *(pagination)* = 9000 possible
items
If you exceed this limit, you'll either have to build a custom and more
specific mapper, or reduce the range in one of your :yaml:`StaticRangeMapper`.
References
----------
* :ref:`TYPO3 Documentation: Routing <t3coreapi:routing-introduction>`
* :ref:`TYPO3 Documentation: Site Handling <t3coreapi:sitehandling>`
* `TYPO3 CMS Core Changelog 9.5: Feature: #86365 - Routing Enhancers and Aspects <https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.5/Feature-86365-RoutingEnhancersAndAspects.html>`__
* `TYPO3 CMS Core Changelog 9.5: Feature: #86160 - PageTypeEnhancer for mapping &type parameter <https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.5/Feature-86160-PageTypeEnhancerForMappingTypeParameter.html>`__

View File

@@ -0,0 +1,228 @@
.. include:: /Includes.rst.txt
.. _rss:
========
RSS feed
========
Displaying a RSS feed is the same as a normal list view, just with a different template.
Therefore you won't need any different configuration to e.g. excluded categories or configure the single view page.
.. only:: html
.. contents::
:local:
:depth: 3
The template for the RSS feed can be found in the file Resources/Private/Templates/News/List.xml.
The "magic" which uses the List.xml template instead of the List.html is the following configuration:
.. code-block:: typoscript
plugin.tx_news.settings.format = xml
# If you want atom, use
plugin.tx_news.settings.format = atom
RSS feed by TypoScript
^^^^^^^^^^^^^^^^^^^^^^
A very simple way to generate the RSS feed is using plain TypoScript. All you need is to use the given TypoScript and adopt it to your needs.
.. code-block:: typoscript
pageNewsRSS = PAGE
pageNewsRSS {
# Override the typeNum if you have more than one feed
typeNum = {$plugin.tx_news.rss.channel.typeNum}
config {
disableAllHeaderCode = 1
xhtml_cleaning = none
admPanel = 0
debug = 0
disablePrefixComment = 1
metaCharset = utf-8
additionalHeaders.10.header = Content-Type:application/rss+xml;charset=utf-8
absRefPrefix = {$plugin.tx_news.rss.channel.link}
linkVars >
}
10 < tt_content.list.20.news_pi1
10 {
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
categories = 9
categoryConjunction = notor
limit = 30
detailPid = 25
startingpoint = 24
format = xml
# Override the typeNum if you have more than one feed, must be the same as above!
#list.rss.channel.typeNum = {$plugin.tx_news.rss.channel.typeNum}
}
}
}
This example will show all news records which don't have the category with the uid 9 assigned and are saved on the page with uid 24. The single view page is the one with uid 25.
The RSS feed itself can be found with the link :code:`/?type=9818`.
RSS feeds by using a normal plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sometimes it is more convenient to generate the RSS feed using the normal plugin.
The biggest advantage is that the complete configuration can be done within the backend without touching TypoScript.
To create a RSS feed based on a plugin follow this steps:
#. Create a new page.
#. Add the news plugin and define the configuration you need. E.g. startingpoint, page with the single view, ...
#. Define a new TypoScript template and use a code like below. **Very
important**: Use :typoscript:`config.absRefPrefix = http://www.yourdomain.tld/` to
produce absolute urls for links and images!
.. code-block:: typoscript
page = PAGE
page.10 < styles.content.get
config {
# deactivate Standard-Header
disableAllHeaderCode = 1
# no xhtml tags
xhtml_cleaning = none
admPanel = 0
# define charset
metaCharset = utf-8
additionalHeaders.10.header = Content-Type:application/rss+xml;charset=utf-8
disablePrefixComment = 1
linkVars >
}
# set the format
plugin.tx_news.settings.format = xml
# delete content wrap
tt_content.stdWrap >
tt_content.stdWrap.editPanel = 0
# Use custom template for List.html of EXT:fluid_styled_content
lib.contentElement.templateRootPaths.5 = EXT:news/Resources/Private/Examples/Rss/fluid_styled_content/Templates
.. warning::
If your output still contains HTML code, please check your TypoScript (especially fluid\_styled\_content) as this HTML is produced there!
Automatic RSS feeds - based on plugins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are usecases where many different list views are needed and each list view should also get its own RSS feed **without any additional configuration**.
The TypoScript code looks like this.
.. code-block:: typoscript
[globalVar = TSFE:type = {$plugin.tx_news.rss.channel.typeNum}]
lib.stdheader >
tt_content.stdWrap.innerWrap >
tt_content.stdWrap.wrap >
tt_content.stdWrap.editPanel = 0
# get away <div class="feEditAdvanced-firstWrapper" ...> if your logged into the backend
styles.content.get.stdWrap >
# Use custom template for List.html of EXT:fluid_styled_content
lib.contentElement.templateRootPaths.5 = EXT:news/Resources/Private/Examples/Rss/fluid_styled_content/Templates
pageNewsRSS = PAGE
pageNewsRSS.typeNum = {$plugin.tx_news.rss.channel.typeNum}
pageNewsRSS.10 < styles.content.get
pageNewsRSS.10.select.where = colPos=0 AND list_type = "news_pi1"
pageNewsRSS.10.select {
orderBy = sorting ASC
max = 1
}
config {
# deactivate Standard-Header
disableAllHeaderCode = 1
# no xhtml tags
xhtml_cleaning = none
admPanel = 0
# define charset
metaCharset = utf-8
# you need an english locale to get correct rfc values for <lastBuildDate>, ...
locale_all = en_EN
# CMS 8 (adjust if using ATOM)
additionalHeaders.10.header = Content-Type:application/xml;charset=utf-8
disablePrefixComment = 1
baseURL = {$plugin.tx_news.rss.channel.link}
absRefPrefix = {$plugin.tx_news.rss.channel.link}
linkVars >
}
# set the format
plugin.tx_news.settings.format = xml
[global]
**Some explanations**
The page object pageNewsRSS will render only those content elements which are in colPos 0 and are a news plugin. Therefore all other content elements won't be rendered in the RSS feed.
Misc
^^^^
RSS feed configuration
""""""""""""""""""""""
Don't forget to configure the RSS feed properly as the sample template won't fulfill your needs completely. Please look up the constants and change the mentioned settings.
.. code-block:: typoscript
plugin.tx_news.rss.channel {
title = Dummy Title
description =
link = http://example.com
language = en-gb
copyright = TYPO3 News
category =
generator = TYPO3 EXT:news
}
Add a link to the RSS feed in the list view
"""""""""""""""""""""""""""""""""""""""""""
To be able to render a link in the header section of the normal page which points to the RSS feed you can use something like this in your List.html Fluid template.
.. code-block:: html
<n:headerData>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="{f:uri.page(pageType: settings.list.rss.channel.typeNum)}" />
</n:headerData>
Troubleshooting
^^^^^^^^^^^^^^^
Entity 'nbsp' not defined
"""""""""""""""""""""""""
If you are getting this error, the easiest thing is to replace the character by using TypoScript:
.. code-block:: typoscript
pageNewsRSS.10.stdWrap.replacement {
10 {
search = &nbsp;
replace = &#160;
}
}

View File

@@ -0,0 +1,274 @@
.. include:: /Includes.rst.txt
.. _seo:
===
SEO
===
This chapters covers all configurations which are relevant for search engine optimization
regarding the news extension.
.. note::
All settings described require TYPO3 9 and the the system extension "seo" installed.
.. only:: html
.. contents::
:local:
:depth: 2
Page title for single news
--------------------------
EXT:news implements a custom *pageTitleProvider* `\GeorgRinger\News\Seo\NewsTitleProvider` which is called through the controller.
It can be configured using TypoScript:
.. code-block:: typoscript
plugin.tx_news.settings.detail {
pageTitle = 1
pageTitle {
# Register alternative provider
provider = GeorgRinger\News\Seo\NewsTitleProvider
# Comma separated list of properties which should be checked, 1st value is used
properties = teaser,title
}
}
It is also possible to set the page title through the template by using:
.. code-block:: html
<n:titleTag>
<f:format.htmlentitiesDecode>{newsItem.title}</f:format.htmlentitiesDecode>
</n:titleTag>
Please disable the usage of the page title provider by using
.. code-block:: typoscript
plugin.tx_news.settings.detail.pageTitle = 0
XML Sitemap
-----------
The sitemap includes links to all news records. This makes it easier for search engines to find all news records and to index those.
Depending on your requirements you can either use the simple sitemap provider from the Core or a custom one shipped with EXT:news.
Basic sitemap
~~~~~~~~~~~~~
The Core ships a basic sitemap configuration which can also be used for news records:
.. code-block:: typoscript
plugin.tx_seo.config {
xmlSitemap {
sitemaps {
news {
provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
config {
table = tx_news_domain_model_news
additionalWhere =
sortField = sorting
lastModifiedField = tstamp
changeFreqField = sitemap_changefreq
priorityField = sitemap_priority
pid = 26
recursive = 2
url {
pageId = 25
fieldToParameterMap {
uid = tx_news_pi1[news]
}
additionalGetParameters {
tx_news_pi1.controller = News
tx_news_pi1.action = detail
}
}
}
}
}
}
}
Extended sitemap
~~~~~~~~~~~~~~~~
The :php:`GeorgRinger\News\Seo\NewsXmlSitemapDataProvider` provides the same feature set as
:php:`RecordsXmlSitemapDataProvider` but with some additional ones on top:
- If you are using the feature to define the detail page through the field
:guilabel:`Single-view page for news from this category` of a :sql:`sys_category` you need to use a custom provider.
- If you are need urls containing day, month or year information
- Setting :typoscript:`excludedTypes` to exclude certain news types from the sitemap
- Setting :typoscript:`googleNews` to load the news differently as required for Google News (newest news first and limit to last two days)
To enable the category detail page handling, checkout the setting :typoscript:`useCategorySinglePid = 1` in the following full example:
.. code-block:: typoscript
plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
news {
provider = GeorgRinger\News\Seo\NewsXmlSitemapDataProvider
config {
excludedTypes = 1,2
additionalWhere =
## enable these two lines to generate a Google News sitemap
# template = EXT:news/Resources/Private/Templates/News/GoogleNews.xml
# googleNews = 1
sortField = datetime
lastModifiedField = tstamp
pid = 84
recursive = 2
url {
pageId = 116
useCategorySinglePid = 1
hrDate = 0
hrDate {
day = j
month = n
year = Y
}
fieldToParameterMap {
uid = tx_news_pi1[news]
}
additionalGetParameters {
tx_news_pi1.controller = News
tx_news_pi1.action = detail
}
}
}
}
}
}
}
}
Multiple Sitemaps
~~~~~~~~~~~~~~~~~
With TYPO3 10 it is possible to define multiple sitemaps. This can be used to define a normal sitemap and one for google news. This example adds another sitemap for the google news and defines a new type.
.. code-block:: typoscript
plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
news {
provider = GeorgRinger\News\Seo\NewsXmlSitemapDataProvider
config {
# ...
}
}
}
googleNewsSitemap {
sitemaps {
news < plugin.tx_seo.config.xmlSitemap.sitemaps.news
news {
config {
template = EXT:news/Resources/Private/Templates/News/GoogleNews.xml
googleNews = 1
}
}
}
}
}
}
seo_sitemap_news < seo_sitemap
seo_sitemap_news {
typeNum = 1533906436
10.sitemapType = googleNewsSitemap
}
This sitemap can be added in the site config so it has a nice url:
.. code-block:: yaml
:linenos:
routeEnhancers:
PageTypeSuffix:
map:
news_sitemap.xml: 1533906436
.. _seo_language_menus:
Language menu on news detail pages
----------------------------------
If a language menu is rendered on a detail page and the languages are configured to use a strict mode, the following snippet helps you to setup a proper menu.
If no translation exists, the property `available` is set to `false` - just as if the current page is not translated.
.. code-block:: typoscript
10 = TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor
10 {
as = languageMenu
addQueryString = 1
}
11 = GeorgRinger\News\DataProcessing\DisableLanguageMenuProcessor
# comma separated list of language menu names
11.menus = languageMenu
See also chapter :ref:`LanguageMenuProcessor <dataProcessing_LanguageMenuProcessor>`.
Hreflang on news detail pages
-----------------------------
If using languages with the language mode `strict`, the hreflang tag must only be generated if the according news record is translated as well!
.. note::
This feature is only supported by TYPO3 10 and up, described
in :ref:`TYPO3 Explained, ModifyHrefLangTagsEvent<t3coreapi:ModifyHrefLangTagsEvent>`.
EXT:news reduces the rendered hreflang attributes by using this event and checking the availability of the records.
Check availability in Fluid templates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are building a language menu and want to check if the news record is available, you can use the ViewHelper
:html:`<n:check.pageAvailableInLanguage language="{languageId}">`. A full example can look like this:
.. code-block:: html
<ul>
<f:for each="{LanguageMenu}" as="item">
<f:if condition="{item.available}">
<n:check.pageAvailableInLanguage language="{item.languageId}">
<li class="language-switch {f:if(condition:item.active, then:'active')}">
<a href="{item.link}">{item.navigationTitle}</a>
</li>
</n:check.pageAvailableInLanguage>
</f:if>
</f:for>
</ul>
Robots: allow indexing of news records, but set 'noindex' to the detail page
----------------------------------------------------------------------------
By default, the detail page will be listed in the SEO sitemap.
But in most cases, you don't want the page itself to be indexed by search engines (means: without a news record to be shown by the plugin).
If you just disable *Index this page* (`no_index`) in the page properties, the robots meta tag with *noindex* value will also be applied to the news records.
Solution: You can use the following TypoScript condition to allow search engines to index the page again, if a news record is rendered:
.. code-block:: typoscript
[traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
page.meta.robots = index,follow
page.meta.robots.replace = 1
[global]
An important part is the `replace` option. The MetaTag API of TYPO3 will then replace tags which were set before.

View File

@@ -0,0 +1,64 @@
.. include:: /Includes.rst.txt
.. _general_tsconfig_examples:
======================
TSconfig code snippets
======================
Page TSconfig from can be used to influence display and behaviour of fields and
forms in the backend. The following examples are for your convenience only, they
are possible with any record type in TYPO3. Read more about what you can do with
page TSconfig in the :doc:`TSconfig Reference <t3tsconfig:Index>`.
You want to add your example here? Hit the "Edit on Github" button in the top
right and make a pull request on Github.
Setting default values
======================
It is possible to set default values for each field in the backend:
.. code-block:: typoscript
TCAdefaults.tx_news_domain_model_news {
author = Jon Doe
notes = Someone forgot to change the notes....
}
Categories
==========
Set a default category
----------------------
Setting default values also works for categories:
.. code-block:: typoscript
TCAdefaults.tx_news_domain_model_news {
categories = 9
}
Limit categories to just one or several roots
---------------------------------------------
In many installations categories are used for multiple purposes. If you want
to use certain category trees only in certain page trees or only for your news
records, you can set the following
.. versionadded:: TYPO3 11.4
:typoscript:`treeConfig.startingPoints` was added with TYPO3 11.4
.. code-block:: typoscript
TCEFORM.tx_news_domain_model_news.categories.config.treeConfig.startingPoints = 8,42
.. deprecated:: TYPO3 11.4
Before TYPO3 11.4 it was only possible to set one value as category root:
.. code-block:: typoscript
TCEFORM.tx_news_domain_model_news.categories.config.treeConfig.rootUid = 42
See also :ref:`TSconfig Reference, treeConfig <t3tsconfig:pageTsConfigTceFormConfigTreeConfig>`.