Sitemap for events2 - typo3

I use TYPO3 v10.4.24, events2 v7.1. and the core SEO extension tx_seo.
I configure the sitemap for events2 this way:
plugin.tx_seo {
config {
xmlSitemap {
sitemaps {
events2 {
provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
config {
table = tx_events2_domain_model_event
sortField = tstamp
lastModifiedField = tstamp
pid = 2061
recursive = 2
url {
pageId = 917 //PageID Detail Page
fieldToParameterMap {
uid = tx_events2_events[event]
}
additionalGetParameters {
tx_events2_events.controller = Day
tx_events2_events.action = show
}
useCacheHash = 1
}
}
}
}
}
}
}
The sitemap is generated and I can show the detail view. Google accepts the sitemap, too. But the URLs are ugly because the route enhancer is not used. This is my configuration of the route enhancer.
Events2Plugin:
type: Extbase
extension: Events2
plugin: Events
routes:
- { routePath: '', _controller: 'Day::list' }
- { routePath: '/{date}/{event_title}', _controller: 'Day::show', _arguments: { date: 'timestamp', event_title: 'event' }}
- { routePath: '/events/{date}', _controller: 'Day::showByTimestamp', _arguments: { date: 'timestamp' }}
- { routePath: '/{location}', _controller: 'Location::show', _arguments: { location: 'location' }}
- { routePath: '/listpage-{page}', _controller: 'Day::list', _arguments: { page: '#widget_0/currentPage' }}
defaultController: 'Day::list'
defaults:
page: '0'
requirements:
date: '\d+-\d+-\d+_\d+'
event_title: '^[a-zA-Z0-9\-_]+$'
aspects:
date:
type: TimestampMapper
format: Y-m-d_Hi
event_title:
type: PersistedAliasMapper
tableName: tx_events2_domain_model_event
routeFieldName: path_segment
location:
type: PersistedAliasMapper
tableName: tx_events2_domain_model_location
routeFieldName: slug
page:
type: StaticRangeMapper
start: '1'
end: '100'
What can I do that the route enhancer is used as with other extensions.

Your RouteEnhancer configuration for detail view requires a {date}. You only add action and controller to URI in Sitemap configuration.
Please add
tx_events2_events.timestamp = 0
to section „additionalGetParameters“

Related

TYPO3 Undefined array key 1

I have an extbase extension. If I add a new item then I see this error:
PHP Warning: Undefined array key 1 in
/var/www/html/typo3/typo3_src-11.5.13/typo3/sysext/extbase/Classes/Routing/ExtbasePluginEnhancer.php line 202
My method:
public function listAction(): ResponseInterface
{
// List
if ($this->settings['display'] == '0') {
if ($this->settings['categories'] != '') {
if ($this->settings['important'] != '0') {
$articles = $this->getImportantFromCategories();
} else {
$articles = $this->getFromCategories();
}
} else {
if ($this->settings['important'] != '0') {
$articles = $this->getImportantArticles();
} else {
$articles = $this->getArticles();
}
}
}
// Archive
if ($this->settings['display'] == '2') {
$articles = $this->getArchivedArticles();
}
// If not details
if ($this->settings['display'] != '1') {
// Pagination
$articlesArray = $articles->toArray();
$currentPage = $this->request->hasArgument('currentPage') ? $this->request->getArgument('currentPage') : 1;
$paginator = new ArrayPaginator($articlesArray, intval($currentPage), intval($this->settings['perpage']));
$simplePagination = new SimplePagination($paginator);
$articles = $this->articleRepository->findAll();
$this->view->assignMultiple(
[
'articles' => $articles,
'paginator' => $paginator,
'pagination' =>
[
'lastPageNumber' => $simplePagination->getLastPageNumber(),
'firstPageNumber' => $simplePagination->getFirstPageNumber(),
'nextPageNumber' => $simplePagination->getNextPageNumber(),
'previousPageNumber' => $simplePagination->getPreviousPageNumber(),
'startRecordNumber' => $simplePagination->getStartRecordNumber(),
'endRecordNumber' => $simplePagination->getEndRecordNumber(),
'currentPageNumber' => $paginator->getCurrentPageNumber(),
'pages' => $simplePagination->getAllPageNumbers(),
'article_counter' => $this->article_counter,
],
'article_counter' => $this->article_counter,
]
);
}
return $this->htmlResponse();
}
and the getArticles() method:
public function getArticles()
{
$table = 'tx_extension_domain_model_article';
$query = $this->articleRepository->createQuery();
if ($this->settings['sorting'] == 'list') {
$query->statement('SELECT * FROM ' . $table . ' WHERE archived != 1');
} else {
$query->statement('SELECT * FROM ' . $table . ' WHERE archived != 1 ORDER BY crdate DESC');
}
$this->article_counter = $query->count();
return $query->execute();
}
I don't know why this error message is triggered.
The only change is the PHP Version from 7.4 to 8.0.21.
My route enhancer
routeEnhancers:
Plugin:
type: Extbase
extension: Plugin
plugin: News
routes:
- routePath: '/{slug}'
_controller: 'Article::show'
_arguments:
slug: article
- routePath: '/page/{page}'
_controller: 'Article'
_arguments:
page: currentPage
defaultController: 'Article::list'
requirements:
slug: '^[a-zA-Z0-9].*$'
page: '\d+'
aspects:
slug:
type: PersistedAliasMapper
tableName: tx_extension_domain_model_article
routeFieldName: slug
page:
type: StaticRangeMapper
start: '1'
end: '100'
You should look up your extbase plugin route enhancer configuration in your site configuration.
Reading the given error, and look into the corresponding code, it seems that you have a invalid value for a '_controller' or 'defaultController' configuration in there.
It should be something like MyController::myaction .. and taken the error, the second part "::myaction" seems to be missing.
The first error
PHP Warning: Undefined array key 1 in
/var/www/html/typo3/typo3_src-11.5.13/typo3/sysext/extbase/Classes/Routing/ExtbasePluginEnhancer.php line 202
Is solved by adding ::list in the route
- routePath: '/page/{page}'
_controller: 'Article::list'
_arguments:
page: currentPage
This will trigger
PHP Warning: Undefined array key "nonWrappedTag" in /var/www/html/typo3/typo3_src-11.5.14/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 3812
Solved with this TypoScript setup code
lib.parseFunc_teaser < lib.parseFunc_RTE
lib.parseFunc_teaser.nonTypoTagStdWrap.encapsLines >
lib.parseFunc_teaser.nonTypoTagStdWrap.encapsLines {
encapsTagList = p
remapTag.P =
nonWrappedTag =
}
The lines
encapsTagList = p
remapTag.P =
are not important.

softdeleteable filter not working in Symfony with mongodb

We are creating an API-REST with Symfony 3.4 and using mongodb as db
All the mapping and cofiguration has been done, and it works.
buuuuuuuttt...
The softdeleteable filter is not working, I mean:
If I "delete" one document, the deletedAt works fine.
Then, if I try to get all the documents of this collection, or even just THAT document, I CAN DO IT !!! even if it's deleted.
And if I delete again that same document, it is fully deleted from the database.
This is my config.yml :
stof_doctrine_extensions:
default_locale: '%locale%'
mongodb:
default:
timestampable: true
softdeleteable: true
translatable: true
loggable: true
uploadable: true
translation_fallback: true
uploadable:
default_file_path: "%kernel.root_dir%/../web/files/"
# Doctrine Configuration
doctrine_mongodb:
default_database: "%mongodb_default_db%"
document_managers:
default:
retry_connect: 5
retry_query: 5
auto_mapping: true
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\ODM\SoftDeleteableFilter
enabled: true
mappings:
#translatable
gedmo_translatable:
type: annotation
alias: GedmoTranslatable
prefix: Gedmo\Translatable\Document
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Document"
is_bundle: false
#loggable
gedmo_loggable:
type: annotation
alias: GedmoLoggable
prefix: Gedmo\Loggable\Document
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Document"
is_bundle: false
proxy_namespace: MongoDBODMProxies
proxy_dir: "%kernel.cache_dir%/doctrine/odm/mongodb/Proxies"
auto_generate_proxy_classes: '%kernel.debug%'
An example of the mapping:
Example\ExampleBundle\Model\Example:
collection: example
gedmo:
loggable: true
translation:
locale: locale
soft_deleteable:
field_name: deletedAt
time_aware: false
fields:
id:
type: object_id
id: true
name:
type: string
nullable: false
gedmo:
- translatable
- versioned
description:
type: string
nullable: false
gedmo:
- translatable
- versioned
createdAt:
name: created_at
type: date
gedmo:
timestampable:
on: create
updatedAt:
name: updated_at
type: date
gedmo:
timestampable:
on: update
deletedAt:
name: deleted_at
type: date
nullable: true
And my model:
class Example
{
private $id;
...
private $createdAt;
private $updatedAt;
private $deletedAt;
public function getId()
{
return $this->id;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getDeletedAt()
{
return $this->deletedAt;
}
}
In the controller, for example, to get a document by its ID, I have:
/**
* Get a single entity.
*
* #ApiDoc(
* resource=true,
* description="Get a single Example.",
* output= {"class"=Example::class},
* statusCodes={
* 200="Returned when successful",
* 404="Returned when not found"
* },
* parameters={
* {"name"="id", "dataType"="integer", "required"=true, "description"="Example id"}
* }
* )
*
* #FOS\Get("/example/{id}", requirements={"id": "([a-f\d]{24})|(\d+)"})
* #FOS\View
*
* #param Example $example
*
* #return Response
*/
public function getExampleAction(Example $example)
{
return array('example' => $example);
}
please, what am I doing wrong?
I have already 2 days trying different things but nothing :(
in the documentation it's say:
"For now, it works only with the ORM"
https://github.com/stof/DoctrineExtensions/blob/master/doc/softdeleteable.md
So i think it's not totally works with ODM, sorry.
Can you complete your querys to check the deletedAt field?

Inaccessible site Symfony routing

Can anyone please help me I'm desperate here !!!
I am working on a symfony 3 project and I have different actions to persist data to database or to update it but none of them is working. The code is fine I'm guessing it's a problem with the routing. This one is the action to add element to database
public function newAction(Request $request)
{
...
if($request->isMethod('POST')) {
...
return $this->redirectToRoute('meeting_new', array(
'meeting' => $meeting
));
...
}
return $this->render('SocialProMeetingBundle::ajoutMeeting.html.twig', array('users'=>$users));
}
and this is the updating action
public function editAction(Request $request, Meeting $meeting)
{
...
if($request->isMethod('POST')) {
...
return $this->redirectToRoute('meeting_edit', array(
'id' => $meeting->getId()
));
}
return $this->render('meeting/edit.html.twig', array(
'meeting' => $meeting,
));
}
and this is my routing file
meeting_index:
path: /
defaults: { _controller: "SocialProMeetingBundle:Meeting:index" }
methods: GET
meeting_show:
path: /show
defaults: { _controller: "SocialProMeetingBundle:Meeting:show" }
methods: [GET, POST]
meeting_new:
path: /new
defaults: { _controller: "SocialProMeetingBundle:Meeting:new" }
methods: [GET, POST]
meeting_edit:
path: /{id}/edit
defaults: { _controller: "SocialProMeetingBundle:Meeting:edit" }
methods: [GET, POST]
meeting_delete:
path: /{id}/delete
defaults: { _controller: "SocialProMeetingBundle:Meeting:delete" }
methods: DELETE
One problem is in your function newAction where you are passing in a meeting parameter and the route doesn't handle it. This code:
return $this->redirectToRoute('meeting_new', array(
'meeting' => $meeting
));
Your route needs to handle the parameter like so:
meeting_new:
path: /new/{meeting}
defaults: { _controller: "SocialProMeetingBundle:Meeting:new" }
methods: [GET, POST]

RouterConfiguration and Router undefined in aurelia

I am very new to Aurelia and just trying to apply navigation to my project.Though i import aurelia-router still it says RouterConfiguration and Router are undefined in constructor
import {Todo} from './ToDo/todo';
import {RouterConfiguration, Router} from 'aurelia-router';
export class App {
heading = "Todos";
todos: Todo[] = [];
todoDescription = '';
router :any;
list: any[];
constructor(RouterConfiguration: RouterConfiguration, Router: Router) {
this.todos = [];
this.configureRouter(RouterConfiguration, Router);
//console.log("klist", this.list);
}
//config.map() adds route(s) to the router. Although only route, name,
//moduleId, href and nav are shown above there are other properties that can be included in a route.
//The class name for each route is
configureRouter(config: RouterConfiguration, router: Router): void {
this.router = router;
config.title = 'Aurelia';
config.map([
{ route: '', name: 'home', moduleId: 'home/home', nav: true, title: 'Home' },
{ route: 'users', name: 'users', moduleId: './Friends/Friends', nav: true },
//{ route: 'users/:id/detail', name: 'userDetail', moduleId: 'users/detail' },
//{ route: 'files/*path', name: 'files', moduleId: 'files/index', href: '#files', nav: 0 }
]);
}
addTodo() {
if (this.todoDescription) {
this.todos.push(new Todo(this.todoDescription));
// this.todoDescription = '';
}
}
}
By convention, Aurelia looks in the initial class that loads (App) for the configureRouter() function and executes it. This means, you do not have to inject anything in the constructor.
It looks like you've simply added too much. I think fixing your sample seems to be as easy as removing some stuff, like so:
import { Todo } from './ToDo/todo';
import { RouterConfiguration, Router } from 'aurelia-router';
export class App {
heading = "Todos";
todos: Todo[] = [];
todoDescription = '';
list: any[];
constructor() {
// note: removed routing here entirely (you don't need it)
// also, you've already declared this.todos above, so no need to do it here again
}
configureRouter(config : RouterConfiguration, router : Router): void {
this.router = router;
config.title = 'Aurelia';
config.map([
{ route: '', name: 'home', moduleId: 'home/home', nav: true, title: 'Home' },
{ route: 'users', name: 'users', moduleId: './Friends/Friends', nav: true }
]);
}
addTodo() {
// removed this for brevity
}
}
This should resolve your 'undefined' errors on Router and RouteConfiguration. As an additional note, don't forget to add the <router-view> to your html template as well. Otherwise, you'll get no errors but the views won't show up either:
<template>
<div class="content">
<router-view></router-view>
</div>
</template>
Great documentation on this can be found at the Aurelia Docs - Routing.

Symfony - how to add embed Forms?

I am trying to create a form Houses and embed the Images forms into it. I have follow the tutorial http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-Forms.
I have the following schema:
houses:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true }
description: { type: string(5000), notnull: true }
images:
actAs: { Timestampable: ~ }
columns:
url: { type: string(255), notnull: true }
id_house: { type: integer, notnull: true }
relations:
houses: { local: id_house, foreign: id, foreignAlias: HousesImg}
and the code :
//lib/form/doctrine/ImagesCollectionForm
class ImagesCollectionForm extends sfForm
{
public function configure()
{
if(!$house= $this->getOption('house'))
{
throw new InvalidArgumentException('You must provide an house');
}
for ($i = 0; $i < $this->getOption('size',2); $i++)
{
$images = new images();
$images->house = $house;
$form = new imagesForm($images);
$this->embedForm($i, $form);
}
}
}
//lib/form/doctrine/housesForm.class.php
public function configure()
{
$form = new ImagesCollectionForm(null, array('house' => $this->getObject(),'size'=>2));
$this->embedForm('images', $form);
}
The fields are displayed as expected. But, when I press the save button I get a blank page and the data aren't saved in database.
use have not specified alias in Images relation with product
so by default symfony look it for relation name
so u need to change $images->house = $house; to $images->houses = $house;
or u can set alias in relation
hope this will help.