TYPO3 - tx_news Speaking URL route if storage out of root page lead to error "The requested page does not exist" - typo3-9.x

There are existing websites with page tree
Root Website 1
Folder: News Storage 1
Page: News List/Detail 1
Root Website 2
Folder: News Storage 2
Page: News List/Detail 2
When I try to show on "News List/Detail 2" Entity form "News Storage 1" its work for the list view. But in detail view, I have Error "The requested page does not exist" And the opposite.
If place Storage folder in the same level root page - don't work.
Also, if delete routeEnhancers From Site configuration - all works. It's simple:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
defaultController: 'News::list'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
Looks like a problem with URL route. But how fix?
I use TYPO3 9.5.22, tx_news 7.3.1.
Question. How allow show entity in detail view from other root pages and use URL routing? Thx for the advice :)
Update: Same problem for another routing like Extbase. If skip SLUG from routing configuration all works). Like, use title instead of the slug. Should be a problem in slug prefix or suffix logic.
So config like that
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
defaultController: 'News::list'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: uid
Works but URLs are not the best looking (. Why slug is buggy?

I found the answer in other case here https://stackoverflow.com/a/61673990/4796923. I pretty sure that this case will appear for other developers.
The problem in slug configuration:
Original configuration
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['path_segment']['config'] = [
'type' => 'slug',
'size' => 50,
'generatorOptions' => [
'fields' => ['title'],
'replacements' => [
'/' => '-'
],
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
'default' => ''
];
option eval' => 'uniqueInSite' don't work if you need use Entitties over cross website, so you need replace to eval' => 'unique'
And all works. Im my case also was needed add routeValuePrefix: '' in routing config like
aspects:
fund_slug:
type: PersistedAliasMapper
tableName: tx_lloyd_domain_model_fund
routeFieldName: slug
routeValuePrefix: ''
But for tx_news firs fix works

Related

Nuxt dynamic url param for application

I'm quite new to Vue and Nuxt and I built a web app. I need to show url based on city, but don't know what kind of routing is this.
I have web app under domain mydomain.com and there are pages like:
/ - for home page (mydomain.com)
/list - for list of items (mydomain.com/list)
/list/123 - item page, where 123 is id of item (mydomain.com/list/123)
What I want it is to get user's location and write it to vuex store and show urls with city prefix always, so it will look like:
/paris/ - for home page (mydomain.com/paris)
/paris/list - for list of items (mydomain.com/paris/list)
/paris/list/123 - item page, where 123 is id of item (mydomain.com/paris/list/123)
User will be able to change city using dropdown. I'm using nuxt and all url parts are used from pages, but in this case city is not the page it is kind of param. Please advice where to look.
It's achievable using vue-router. You can setup paths there like:
{
path: '/:city',
name: 'City',
component: City
},
{
path: '/:city/list',
name: 'List',
component: ListCmp
},
{
path: '/:city/list/:id',
name: 'ItemPage',
component: ItemPageCmp
},
Your template link for the ListCmp would be:
<router-link :to="{name: 'List', params: {city: 'Paris'}}">Paris</router-link>
And in your component you would access your param:
this.$route.params.city

Netlify CMS nested YAML using Middleman

I'm trying to get my Middleman page set up with Netlify CMS. I'm using have the following file structure:
data
> pages
> page1.yml
> page2.yml
Each page has this content:
de:
title: Title in German
en:
title: Title in English
Now I'd like to be able to edit these pages in Netlify CMS and basically have two text fields per page ("Title (DE)" and "Title (EN)").
I tried it with this config:
collections:
- label: Pages
name: pages
folder: data/pages/
fields:
- { label: Title (DE), name: de.title, widget: string, required: true }
- { label: Title (EN), name: en.title, widget: string, required: true }
But nothing shows up in the Netlify CMS backend:
What am I doing wrong?
I'm guessing your files aren't markdown with frontmatter? If you're using data files, eg. json/yaml/toml, you'll need to set the extension for the collection: https://www.netlifycms.org/docs/configuration-options/#extension-and-format
Also, you need a field named title, or else set identifier_field to the name of the field you'd like to use as the identifier (otherwise your files will show as blank tiles in the UI): https://www.netlifycms.org/docs/configuration-options/#identifier_field

using vue-head with prerender-spa-plugin is causing title and meta tags to be displayed twice on netlify

This issue only happens when live on netlify ( despite their prerender option turned off ), not while being served locally.
the live site shows :
<title>about | anonplayer about | anonplayer</title>
title and meta tags are set using the vue-head package like so
head: {
title: {
inner: "about | anonplayer",
separator: ' ',
}, ...
and this happens for all routes of my single page app and also to meta tags where there are two sets of the tags I intended to have.
looks like this
I used the default prerender settings like so:
config.plugins.push(new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: path.join(__dirname, 'dist'),
// Required - Routes to render.
routes: ['/', '/about'].concat(contracts.map(each => `/${each.abi}/${each.contract}`)),
}))
was the same, but with Angular
in my case helped replacing function this.meta.addTag() with this.meta.updateTag()
so think it's not hosting issue)

Using Frontmatter with Dynamic Pages in Middleman 4

I have spent ample time researching this without finding a solution that worked. I would love it if someone could help me figure this out.
I’m trying to use Dynamic Pages in my setup, but need to include dynamic Frontmatter with this. But I can’t use Frontmatter in the template file, so I was thinking I could use a YAML data file instead? I tried various approaches, but none were successful. The dynamic pages load just fine, but every one of them will use the same Frontmatter unless I can pull in dynamic data instead.
My config includes:
["england", "france"].each do |team|
proxy "/teams/#{team}/index.html", "/teams/team.html", :locals => { :team_name => team }, :ignore => true
end
And my directory structure in this section looks like this:
teams
- index.html.erb
- team.html.erb
I began a YAML data file that includes:
england:
title: "Teams/England"
description: "England"
headline: "England"
addclass: "england cols"
france:
title: "Teams/France"
description: "France"
headline: "France"
addclass: "france cols"
When I use the aforementioned data in the template file as Frontmatter, it works just fine:
---
title: Teams/France
description: France
headline: France
addclass: france cols
---
One example of how I am using the data:
<%= current_page.data.addclass %>
My questions are as follows:
How can I use a YAML data file to serve unique data to each Dynamic Page?
Can I use the final URI segment ( “england” from /teams/england/, “france” from /teams/france/, etc.) to define which data set to use?
Can I do this without impacting other non-dynamic-pages (/matches/, /groups/, etc.) on the site?
Thank you so very much in advance.
I'd suggest changing your data format slightly. It'll allow you to pass the entire local data item to the template so you can use the data without needing to first "load it" into Frontmatter.
Adjust your teams.yml file (I've added the 'slug' value here):
items:
- title: "England"
slug: "england"
description: "England"
headline: "England"
addclass: "england cols"
- title: "France"
slug: "france"
description: "France"
headline: "France"
addclass: "france cols"
Change your config.rb block to (assuming teams.yml is at /data/teams.yml) - note the check to prevent errors if data is missing:
if File.exist?("data/teams.yml")
data.teams.items.each do |item|
p = item
proxy "teams/#{p.slug}.html", "teams/team.html", locals: { item: p }, ignore: true
end
end
This will pass all the data from the team item into the template. You won't have to "define which data set to use", since the template context will refer just to that data item.
Now, in your team.html.erb template, you can reference the data like this (in the template body, not in the Frontmatter):
<h1 class="<%= item.addclass %>"><%= item.title %></h1>
<h2><%= item.description %></h2>
<h3><%= item.headline %></h3>
This should give you two separate pages for England and France with their own unique data.
Unfortunately, Frontmatter doesn't like to be overwritten after a dynamic page is generated in Middleman. For overwriting Frontmatter that you use for metadata, specifically "title", I've had success with gem 'middleman-meta-tags' [ https://github.com/tiste/middleman-meta-tags ] which allows you to override page titles in the template body after it's been defined, sourced from the YAML data.

a route doesnt work (yii)

Hy stackoverflow !
I'm trying to make a form into an external page with Yii 1.1.14 (this is an old site).
I've made a directory into my views call signinPartners and into this one, a php file call signin.
I have also created a controller :
class SigninPartnerController extends Controller
{
public function actionSignin(){
$this->render('/signin');
}
}
He renders the route /signin defined in my config by :
return array(
'' => 'index',
'signin' => 'signinPartners/signin',
);
but when I try the URL http://mylocalserver/signin the site send back Error 404 Unable to resolve the request « signin-partners/signin »..
This is really disturbing because there are other URL's on my website and they work the same way without throwing an error 404. I don't know what I missed... Can somebody help ?
my urlManager :
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false, // do not display index.php in the url
'urlSuffix' => '/',
'rules' => $routesRules, //this variable contains the array defined above
),
I have also check my runtime :
2018/01/17 11:12:16 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'Impossible de résoudre la requête « signinPartners/signin ».' in D:\Windows\Windows\CommonFiles\wamp64\www\MoovTime-Conso\library\Yii\web\CWebApplication.php:286
Stack trace:
#0 D:\Windows\Windows\CommonFiles\wamp64\www\MoovTime-Conso\library\Yii\web\CWebApplication.php(141): CWebApplication->runController('signinPartners...')
#1 D:\Windows\Windows\CommonFiles\wamp64\www\MoovTime-Conso\library\Yii\base\CApplication.php(183): CWebApplication->processRequest()
#2 D:\Windows\Windows\CommonFiles\wamp64\www\MoovTime-Conso\public\frontend\index.php(36): CApplication->run()
#3 {main}
REQUEST_URI=/signin
---
(the exception message is in french and means Unable to resolve the request « signin-partners/signin »)
Ok, big update, i've tried to play with routes.php and I realized that the name of my controller doesn't match with signinPartners. So, I update the routes rules with :
return array(
'' => 'index',
'signin' => 'signinPartner/signin',
);
And now, we have a new error : Controller can't find the view « /signin »..
There is the post Controller can't find the view in Yii which can anwser this question !
ANSWERED
try adding a - in signinPartners.
'signin-partners/signin'
The problem in my case was the action, the directory name in my view that contains the page and the route rule.
first, I update the route rule from :
return array(
'' => 'index',
'signin' => 'signinPartners/signin',
);
to :
return array(
'' => 'index',
'signin' => 'signinPartner/signin', // controlerName/actionName
);
The controller name was wrong.
In a second time, to match with the name of the controller, I simply renamed the directory in views calls signinPartners to signinPartner (only for readability).
Finally I update the action actionSignin that was :
public function actionSignin(){
$this->render('/signin');
}
For :
public function actionSignin(){
$this->render('/signinPartner/signin');
}
Where I change the path with the new directory name.