why Typo3 website v10 show empty sitemap xml in frontend - typo3

I'm using a Typo3 website version 10 and the sitemap is not working properly,
i can see the configuration in the typoscript object browser but in the front-end www.mydomain.ch/?type=1533906435 the xml file is blanc.
Frontend screenshot:
Typoscript object browser screenshot:
seo extension is installed.
the website is multilangage.
what can be missing so that i see the sitemap ?

If this is all you have, then you are missing some key configuration. You need to specify what should be shown. So, on your TypoScript, based on the documentation, you should define what pages/extension etc must be shown. For example:
plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
pages {
config {
excludedDoktypes = 137, 138
additionalWhere = AND (no_index = 0 OR no_follow = 0)
#rootPage = <optionally specify a different root page. (default: rootPageId from site configuration)>
}
}
}
}
}
}
Here is an example for the extension news as well, in case you are using it.
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
}
}
}
}
}
}
}
Here the documentation as well: Documentation

i have solved the problem, i think it was the sourceopt extension installed have a bug, i have update it to the latest version, now i can see the xml sitemap working fine, thanks!

Related

TYPO3 11 set custom page title h1 html

I have TYPO3 11.
I created a Page Title Provider
<?php
declare(strict_types=1);
namespace Myvendor\modellobando\Seo;
use TYPO3\CMS\Core\PageTitle\AbstractPageTitleProvider;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class BandoTitleProvider extends AbstractPageTitleProvider
{
private const DEFAULT_PROPERTIES = 'title';
private const DEFAULT_GLUE = '" "';
public function setTitle(string $title): void
{
$this->title = "ecco ".$title;
}
}
I defined it in template.setup
config.pageTitleProviders {
record {
provider = Goproject\modellobando\Seo\BandoTitleProvider
}
}
It works with meta tag title but the data of the page is not changed, I have to set the tag h1 in html in my layout, how can I do that?
updated question:
As I wrote in comment I tried a query to get info about my model but I don't know how avoid SQL injection using query string parameter (GET) like uid=12
page.10 {
dataProcessing {
1001 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
1001 {
table=mytable
pidInList = 16
markers.uid.field = uid
as = datainfobando
where = (uid = ???)
}
}
}
Using a h1 tag means you are in the body of the HTML document. That content does not have an automated content.
But you can insert it in your page template. If you want it set everywhere you can use the page layout template. You only have to provide the information to your FLUID page template, which can be done easily in typoscript.
Avoiding SQL-injection within a select can be done with using markers and securing them.
Eg. reducing them to integer values.
1001 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
1001 {
table=mytable
pidInList = 16
where = {#uid} = ###recordId###
as = datainfobando
markers {
recordId.data = GP:myId
recordId.intval = 1
}
}

TYPO3: clear cache by tag for custom content element when record in backend is changed

I have a sysfolder with records which get displayed in the frontend via a custom content element.
Now I have the problem that the frontend is not updated when a new record is added or an existing record is changed.
To clear the cache I'm using a hook in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['foobar'] =
\Vendor\Name\Hooks\DataHandler::class . '->clearCachePostProc';
The hook looks like this:
<?php
namespace Vendor\Name\Hooks;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class DataHandler implements SingletonInterface
{
public function clearCachePostProc(array $params): void
{
if (isset($params['table']) && $params['table'] === 'tx_foo_domain_model_bar') {
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$cacheManager->flushCachesByTag('1642782027');
}
}
}
And the content element is implemented with FLUIDTEMPLATE and a dataprocessor:
tt_content {
foo_bar =< lib.contentElement
foo_bar {
templateName = myTemplate
stdWrap.cache {
key = tx_foo_domain_model_bar
tags = 1642782027
lifetime = default
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tx_foo_domain_model_bar
pidInList = {$foo.storage_pid}
as = foobar
}
}
}
}
Everything seems to work but when I hit Cmd+R/Ctrl+R and reload the page or visit it again via the navigation, the page is not updated with the latest content.
I implemented the following solution.
Within the Typoscript Setup add a addPageCacheTag to your custom content element:
tt_content {
foo_bar =< lib.contentElement
foo_bar {
templateName = FooBar
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tx_foo_domain_model_bar
pidInList = {$foo.storage_pid}
as = foobar
}
}
stdWrap.addPageCacheTags = foo_bar
}
}
Add the clearCacheCmd to the Page TSConfig from the storage page like:
TCEMAIN.clearCacheCmd = cacheTag:foo_bar
For testing, add this to your Fluid-Template and be sure to test with a separate browser (without BE login):
<div style="color: red;"><f:format.date format="d.m.Y - H:i:s">now</f:format.date></div>
Kudos to https://daniel-siepmann.de/posts/2019/typo3-content-caching.html
You could use the EXT:Fluid Page Cache
https://extensions.typo3.org/extension/fluid_page_cache
This EXT does all the things you need automatically.

How to choose the template dynamically with fluidpages

I was using fluidpages for template building, and would like to choose the template dynamically based on a field in the fe_users table. For example, most people will see the EXT:default template by default, while some will see EXT:advanced template instead, as they are marked as special.
I tried
plugin.tx_template {
view {
templateRootPaths {
0 = EXT:default/Resources/Private/Templates/
10 {
data = TSFE:fe_user|user|template
wrap = EXT: | /Resources/Private/Templates/
}
}
}
}
But it seems the TS is not parsed and is used directly by fluid, therefore failed.
Any idea or hint is appreciated!
Actually this may be possible. But i can't see an obvious way on how to override the chosen template in the page properties.
To my knowledge, you are required to select a template in the page record.
If you find a possibility to override that one, you could use a TS Setup like this:
EXT:template_package/Configuration/TypoScript/constants.txt:
plugin.tx_templatepackage {
view {
templateRootPaths.default = EXT:template_package/Resources/Private/Templates/
partialRootPaths.default = EXT:template_package/Resources/Private/Partials/
layoutRootPaths.default = EXT:template_package/Resources/Private/Layouts/
}
}
EXT:template_package/Configuration/TypoScript/setup.txt:
plugin.tx_templatepackage {
view {
templateRootPaths.default = {$plugin.tx_templatepackage.view.templateRootPaths.default}
partialRootPaths.default = {$plugin.tx_templatepackage.view.partialRootPaths.default}
layoutRootPaths.default = {$plugin.tx_templatepackage.view.layoutRootPaths.default}
}
}
Above part will setup your global paths.
After that, you'll define your sub packages for templates.
EXT:template_package/Configuration/TypoScript/Basic/setup.txt
plugin.tx_templatepackage {
view {
templateRootPaths.10 = {$plugin.tx_templatepackage.view.templateRootPaths.0}Basic/
partialRootPaths.10 = {$plugin.tx_templatepackage.view.partialRootPaths.0}Basic/
layoutRootPaths.10 = {$plugin.tx_templatepackage.view.layoutRootPaths.0}Basic/
}
}
And
EXT:template_package/Configuration/TypoScript/Advanced/setup.txt
plugin.tx_templatepackage {
view {
templateRootPaths.20 = {$plugin.tx_templatepackage.view.templateRootPaths.0}Advanced/
partialRootPaths.20 = {$plugin.tx_templatepackage.view.partialRootPaths.0}Advanced/
layoutRootPaths.20 = {$plugin.tx_templatepackage.view.layoutRootPaths.0}Advanced/
}
}
Of course you should make them available within TYPO3:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Template Package: Base');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Basic', 'Template Package: Basic');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Advanced', 'Template Package: Advanced');
After all of that, you could override a value — IDK which one — via:
[usergroup = group1-uid]
// override option, which defines the default template
[usergroup = group2-uid]
// override option, which defines the default template
Sorry I can't help you out any further. I tried to dig deeper into EXT:flux and EXT:fluidpages. But i can't see that option.

Access page properties within fluid_styled_content element

I'm trying to extend the fluid_styled_content element "Menu". Within my partial (e.g. typo3conf/ext/my_theme/Resources/Private/Templates/Content/Partials/Menu/Type-1.html I need to access the page properties of the page where the menu CE resides. How can I archive this? {data} contains only the data of the content element.
In {data.pid} you have the uid of the page.
You can use a viewhelper to get the complete pages record (in ext:vhs there is a viewhelper to get any kind of records).
or you can use <f:cObject> and some typoscript to access single values.
Use \TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor.
I cannot check the code right now but you could take this as a starting point:
tt_content.menu.dataProcessing {
30 = \TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
where.dataWrap = uid = {TSFE:id}
as = page
}
}
Afterwards you can access the current page‘s properties via {page.0.property}.
There‘s just one query for each menu content object with this approach while most view helper solutions tend to increase the number of database queries issued.
#undko: The DatabaseQueryProcessor was the perfect hint. But your snippet had two problems I had to fix:
- the TypoScript code needs pidInList to work
- in the Fluid Template there was data missing: pageproperties.0.data.myproperty
Here is my final code that works fine for me:
tt_content.menu.dataProcessing {
30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
where.dataWrap = uid = {TSFE:id}
pidInList = 1
as = pageproperties
}
}
In the Fluid template I use {pageproperties.0.data.tx_mytheme_fieldname}.
I don't know why exactly but I can't access page properties with the proposed solution. I'm using Typo3 10.4.9.
I found an alternative solution :
tt_content.menu dataProcessing {
30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
pidInList = 0
recursive = 99
uidInList = this
as = pageproperties
}
}
Maybe this will help someone else.
More brutal approach; to access the page properties everywhere, for example in a custom content element. Create in the sitepackage Classes/ViewHelper/GetPagePropertiesViewHelper.php :
<?php namespace Xxx\Sitepackage\ViewHelpers;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class GetPagePropertiesViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
{
public function initializeArguments()
{
$this->registerArgument('pid', 'int', 'The page uid to get the pageproperties from', true, 1);
$this->registerArgument('property', 'string', 'A specific page property to be returned', false, null);
}
public function render()
{
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('pages');
$pageProperties = [];
$statement = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($this->arguments['pid'], \PDO::PARAM_INT))
)
->execute();
while ($row = $statement->fetch()) {
$pageProperties[] = $row;
}
if ($property) {
return $pageProperties[0][$property];
}
return $pageProperties[0];
}
}
Usage in a template or partial:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:c="http://typo3.org/ns/Xxx/Sitepackage/ViewHelpers"
data-namespace-typo3-fluid="true">
<c:getPageProperties pid="{data.pid}" property="description"/>
<f:debug><c:getPageProperties pid="{data.pid}"/></f:debug>

TYPO3 and sitemap_generator

I use TYPO3 7.6.10 and sitemap_generator 1.0
I see the sitemap.xml and it generates the map but there are not the categories and tags like "categoy/nameofcategory".
How can I solve it?
The code in template is:
plugin.tx_sitemapgenerator {
urlEntries {
pages = 1
pages {
rootPageId = 1
allowedDoktypes = 1
additionalWhere = doktype!=6
}
}
}
plugin.tx_sitemapgenerator {
urlEntries {
news = 1
news {
active = 1
table = tx_news_domain_model_news
additionalWhere = pid!=0
orderBy = title DESC
limit = 0,1000
lastmod = tstamp
url = TEXT
url {
typolink.parameter = 161
typolink.additionalParams = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]={field:uid}
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
typolink.forceAbsoluteUrl = 1
}
}
}
}
A sitemap for google doesn't contain such stuff as tags and description, so there is no need for the extension to deliver that stuff. Check the specs of creating a sitemap here. Google build a sitemap