Create a page outside the multilingual sections to use with pagelist block.
Permalink
Hi everyone,
I’m using Concrete 8.5.2 for a new site and cannot add a page outside the multilingual sections ( /en & /fr ).
In Concrete 5.7, I am used to build a bilingual site using the multilingual sections where all the pages are under /en ou /fr, the standard way. For my special pages (news article, recipe, event, etc.), I build a shortcut to enter in a composer form. The form contains attributes fields for each language, the form is built to enter both languages at once. Once the composer form is filled, the new page is saved outside the multilingual sections. For events, the page will be saved in /events that makes it a multilingual page. I normally create an event page /en/events & /fr/evenements that contains a page list block to list the pages inside /events/. I’m also using a bit of PHP and a cookie to set the proper language of a multilingual page inside /events/
In 8.5.2, I simply cannot add a new page at 1st level. I was able to create a page in /fr and move it into the Site page (the system page). So my new page « Events » has now the /events/ URL. This is nice, just what I needed, but…
The page list block cannot list the pages inside te Site page, maybe because it’s a system page.
I have attached a 5.7 sitemap screenshot to show you how I normally organise the pages.
How can I add a normal page at 1st level of the Sitemap that will contain other pages and that the page list block will be able to list these pages?
Thank you! ;-)
I’m using Concrete 8.5.2 for a new site and cannot add a page outside the multilingual sections ( /en & /fr ).
In Concrete 5.7, I am used to build a bilingual site using the multilingual sections where all the pages are under /en ou /fr, the standard way. For my special pages (news article, recipe, event, etc.), I build a shortcut to enter in a composer form. The form contains attributes fields for each language, the form is built to enter both languages at once. Once the composer form is filled, the new page is saved outside the multilingual sections. For events, the page will be saved in /events that makes it a multilingual page. I normally create an event page /en/events & /fr/evenements that contains a page list block to list the pages inside /events/. I’m also using a bit of PHP and a cookie to set the proper language of a multilingual page inside /events/
In 8.5.2, I simply cannot add a new page at 1st level. I was able to create a page in /fr and move it into the Site page (the system page). So my new page « Events » has now the /events/ URL. This is nice, just what I needed, but…
The page list block cannot list the pages inside te Site page, maybe because it’s a system page.
I have attached a 5.7 sitemap screenshot to show you how I normally organise the pages.
How can I add a normal page at 1st level of the Sitemap that will contain other pages and that the page list block will be able to list these pages?
Thank you! ;-)
An update... Resolved : 3 - The page is misplaced in Sitemap...
If I change the siteTreeID of page jfgwbhegugdeyufdtddsdtrfgd from 1 to 0 in the Pages DB table. The jfgwbhegugdeyufdtddsdtrfgd page is now completely out of the multilingual sections. I can also click the + at left to view the pages inside, yay. I only see it if I choose to Show the System Pages in Sitemap. This is just great and fine for my use. I have not set the cIsSystemPage to 1, it's still set to 0, afraid that this will not help with the Page List Block to work.
Issue is now half resolved...
This technique is great to add a single page outside the multilingual sections (/fr & /en) of your site. But not working with the Page List Block.
Now, the other half of the issue...
I think that I'm not in the right track. I'm trying this now...
I recovered my DB to delete my jfgwbhegugdeyufdtddsdtrfgd tests.
The Page List Block will not list pages outside the multilingual sections (/fr & /en) of the site. But it can list the pages in another language. And the page list output is in the proper language. Yay! But...
When we click an article to read more and enter the page, it's always in French
The pages are organized this way...
The English News page (with PageList Block)...
http://newwebsite.test/en/news
The French News page (with PageList Block)...
http://newwebsite.test/fr/actualites...
When we click an article to read more, we always get the French page
http://newwebsite.test/fr/actualites/first_news...
But this is the normal behaviour if all the news articles are saved under the French tree ( /fr/actualites/... ).
In our case, we use a multilingual composer forms to enter all the data at once using specific page attributes for each language. Attributes like title_fr, title_en, description_fr, description_en, etc. Some attributes do not need to be doubled like product_price, start_date, end_date, etc.
So, what now??? Hummm...
What if I use the composer pages for the French version and create aliases of these pages in the English tree programmatically, when saving the composer form or with a script & cron job' I'll see???
Let's try that....
Hummm, The Page List Block cannot list alias of pages. Baff, let's keep going forward... In both French and English pages, the Page List block will display the pages below /fr/actualites.
In my Page List template, I hacked the (Read more) URL if the language is English...
In my template, the $url var is the (Read more) URL...
$url = ($page->getCollectionPointerExternalLink() != '') ?
$page->getCollectionPointerExternalLink() :
$nh->getLinkToCollection($page);
And the $lang var is set at top of the file...
$lang = Localization::activeLanguage();
So I added this...
if ($lang == 'en') {
$url = str_replace('/fr/actualites/', '/en/news/', $url);
}
Now, this is working nicely! ;-)
Over all, this is a better way for doing this.
With my technique in in 5.7, the page only had 1 URL for French and English...
http://newwebsite.test/news/first_news...
With this technique we still publish 1 page but have 2 URLs...
http://newwebsite.test/fr/actualites/first_news...
http://newwebsite.test/en/news/first_news...
Now, am trying to create the alias of a page in the English tree when saving the composer form...
I usually (in 5.7) hack/override the Type.php file to add a few lines to get, process and set attributes values or do other custom stuff on the Publish of a composer page.
/concrete/src/Page/Type/Type.php
But in 5.8, the functions have changed and I'm lost.
I guess that I will have to review my switch_language and search blocks too. I hope the search block can search page aliases.
Case closed. Thank you!
Hope this will help someone.
Was a BIG deal for me. Now, I'm confident that I can upgrade my sites from 5.7 to 5.8.
Have a nice day!
If I change the siteTreeID of page jfgwbhegugdeyufdtddsdtrfgd from 1 to 0 in the Pages DB table. The jfgwbhegugdeyufdtddsdtrfgd page is now completely out of the multilingual sections. I can also click the + at left to view the pages inside, yay. I only see it if I choose to Show the System Pages in Sitemap. This is just great and fine for my use. I have not set the cIsSystemPage to 1, it's still set to 0, afraid that this will not help with the Page List Block to work.
Issue is now half resolved...
This technique is great to add a single page outside the multilingual sections (/fr & /en) of your site. But not working with the Page List Block.
Now, the other half of the issue...
I think that I'm not in the right track. I'm trying this now...
I recovered my DB to delete my jfgwbhegugdeyufdtddsdtrfgd tests.
The Page List Block will not list pages outside the multilingual sections (/fr & /en) of the site. But it can list the pages in another language. And the page list output is in the proper language. Yay! But...
When we click an article to read more and enter the page, it's always in French
The pages are organized this way...
The English News page (with PageList Block)...
http://newwebsite.test/en/news
The French News page (with PageList Block)...
http://newwebsite.test/fr/actualites...
When we click an article to read more, we always get the French page
http://newwebsite.test/fr/actualites/first_news...
But this is the normal behaviour if all the news articles are saved under the French tree ( /fr/actualites/... ).
In our case, we use a multilingual composer forms to enter all the data at once using specific page attributes for each language. Attributes like title_fr, title_en, description_fr, description_en, etc. Some attributes do not need to be doubled like product_price, start_date, end_date, etc.
So, what now??? Hummm...
What if I use the composer pages for the French version and create aliases of these pages in the English tree programmatically, when saving the composer form or with a script & cron job' I'll see???
Let's try that....
Hummm, The Page List Block cannot list alias of pages. Baff, let's keep going forward... In both French and English pages, the Page List block will display the pages below /fr/actualites.
In my Page List template, I hacked the (Read more) URL if the language is English...
In my template, the $url var is the (Read more) URL...
$url = ($page->getCollectionPointerExternalLink() != '') ?
$page->getCollectionPointerExternalLink() :
$nh->getLinkToCollection($page);
And the $lang var is set at top of the file...
$lang = Localization::activeLanguage();
So I added this...
if ($lang == 'en') {
$url = str_replace('/fr/actualites/', '/en/news/', $url);
}
Now, this is working nicely! ;-)
Over all, this is a better way for doing this.
With my technique in in 5.7, the page only had 1 URL for French and English...
http://newwebsite.test/news/first_news...
With this technique we still publish 1 page but have 2 URLs...
http://newwebsite.test/fr/actualites/first_news...
http://newwebsite.test/en/news/first_news...
Now, am trying to create the alias of a page in the English tree when saving the composer form...
I usually (in 5.7) hack/override the Type.php file to add a few lines to get, process and set attributes values or do other custom stuff on the Publish of a composer page.
/concrete/src/Page/Type/Type.php
But in 5.8, the functions have changed and I'm lost.
I guess that I will have to review my switch_language and search blocks too. I hope the search block can search page aliases.
Case closed. Thank you!
Hope this will help someone.
Was a BIG deal for me. Now, I'm confident that I can upgrade my sites from 5.7 to 5.8.
Have a nice day!
I'm kind of close to achieve my goal but the Page List Block still cannot list pages inside/under the jfgwbhegugdeyufdtddsdtrfgd page.
My test...
1 - Create the file... /application/single_pages/jfgwbhegugdeyufdtddsdtrfgd.php
With this content...
<?php
$a = new Area('Main');
$a->display($c);
?>
2 - In Concrete > Pages & Themes > Single Pages...
At the top of the page, I simply paste my mame jfgwbhegugdeyufdtddsdtrfgd and click Add.
After the list refresh, I see my new page but the path is incorrect... /fr/jfgwbhegugdeyufdtddsdtrfgd
Then I searched the DB for jfgwbhegugdeyufdtddsdtrfgd.
I changed the Path from /fr/jfgwbhegugdeyufdtddsdtrfgd to /jfgwbhegugdeyufdtddsdtrfgd only 1 place in DB. In PagePaths table.
The page URL /jfgwbhegugdeyufdtddsdtrfgd is now working fine.
3 - The page is misplaced in Sitemap...
The page is placed inside the Accueil page (French home /fr/ ).
I changed the CParenID of the page to 0 in the Pages DB table.
This is kind of OK, I still see the jfgwbhegugdeyufdtddsdtrfgd only if I select to see the French pages in Sitemap but the jfgwbhegugdeyufdtddsdtrfgd page is at the same level as the Accueil page (French home), not inside.
I still have these 2 problems...
In Sitemap, only for the page jfgwbhegugdeyufdtddsdtrfgd, I cannot click the + at left to see the pages inside.
The Page List Block cannot list pages inside/under the jfgwbhegugdeyufdtddsdtrfgd page. When I click Edit Block and choose the jfgwbhegugdeyufdtddsdtrfgd page at the Under a Specific Page option.
I can directly access a page inside/under the jfgwbhegugdeyufdtddsdtrfgd page like...
http://newwebsite.test/jfgwbhegugdeyufdtddsdtrfgd/first_page...
Any ideas?