Redirect parent to newest child
Permalink 2 users found helpful
What I'm trying to accomplish is, I've included a screenshot just in case, making the parent page (directory, screenshot) automatically go to the newest (chronologically) child page (new, screenshot)
Thank you so much! I greatly appreciate it and good job.
thank you!
Found a problem... this causes session issues with permissions. I have created an Editor group that has permissions to Edit the Blog (default built-in C5 blog). The Parent page "Blog" just redirects to the newest child (latest article).
While logged in as Editor (not Admin, curiously enough)...
If you are on the newest child of the blog and click your back button, it logs you out.
If you are on the newest child of the blog and then click another link, it logs you out.
If you are on the newest child of the blog and click "Blog" again, it logs you out.
So, there is an issue with sessions, permissions and this add-on, it seems to me.
While logged in as Editor (not Admin, curiously enough)...
If you are on the newest child of the blog and click your back button, it logs you out.
If you are on the newest child of the blog and then click another link, it logs you out.
If you are on the newest child of the blog and click "Blog" again, it logs you out.
So, there is an issue with sessions, permissions and this add-on, it seems to me.
Hmmm I just setup everything the way you mentioned, however, instead of logging me out, the site is just not showing the edit toolbar at top. I'm still logged in because when I re-visit the blog parent it redirects to the child page and the edit toolbar appears again.
Thank you for reporting this, hopefully have it fixed soon.
Thank you for reporting this, hopefully have it fixed soon.
Actually, after doing a little more poking around, I don't think this is an issue with the addon ...
I believe this is due to the page permissions for the editor user group you've created.
Depending on how you set your permissions the editor may have access to edit the blog parent page but no access for the blog entry ( child ) pages.
Are you using 'Advanced Permissions' ? Can you post your blog parent & blog entry page permissions setup ( even a screen shot will do ) ?
I believe this is due to the page permissions for the editor user group you've created.
Depending on how you set your permissions the editor may have access to edit the blog parent page but no access for the blog entry ( child ) pages.
Are you using 'Advanced Permissions' ? Can you post your blog parent & blog entry page permissions setup ( even a screen shot will do ) ?
We're not using Advanced Permissions.
Screenshots are attached for the Blog parent and Blog Entry child pages.
Editor is checked for both viewer and editor groups.
Screenshots are attached for the Blog parent and Blog Entry child pages.
Editor is checked for both viewer and editor groups.
Okay, I'll need to take a look at this over the weekend. I'm using the advanced permissions and the addon appears to be working with the back button properly. The reason my edit toolbar was not showing up for me was because I had set the permissions for my editor group to only be able to edit the blog parent & blog entry pages, other than that the site never logged me out and I was able to continue editing the site.
If you feel like testing the advanced permissions it might be worth a shot, although I'm by no means an expert in this whole sessions/permissions department.
You can enable advanced permissions by including the following in your config/site.php
If you feel like testing the advanced permissions it might be worth a shot, although I'm by no means an expert in this whole sessions/permissions department.
You can enable advanced permissions by including the following in your config/site.php
define('PERMISSIONS_MODEL', 'advanced');
Sweet! Thank you, sir, I will give it a shot tomorrow! Anyway, great work! I am highly appreciative of this solution to a very common problem. It may not work for me in this particular instance (we'll see tomorrow), but overall it's still totally freaking awesome and simple to use. I appreciate the hell out of that! Cheers (rough day, and yes I am drinking a beer right now...)
Hi Zoinks... or is that Shaggy Doo? :) All's good on my end.
I've setup a base install of concrete5.4.2.1 with the package ( base permissions ), added a user group called 'editor' and added a new user to the group. Works fine for me, no problems ( the user can visit the blog, get redirected automatically, and then use the browser back button ).
I'm wondering if you have your 'Edit Access' set for the 'editor' group to be able to edit the site. It's sorta of a master switch for groups to be able to edit on a site wide level... using advanced permissions does not have this 'switch'. You can find these settings in dashboard/settings/set_permissions/
attached is a screen shot of my settings in a working install with the default base permissions.
The only thing that I did was check the box next to the 'Editor' group as it was un-checked by default.
Hope you get it working, good news is that, so far, the problem is isolated and, as far as I can tell, not with the package itself...
I've setup a base install of concrete5.4.2.1 with the package ( base permissions ), added a user group called 'editor' and added a new user to the group. Works fine for me, no problems ( the user can visit the blog, get redirected automatically, and then use the browser back button ).
I'm wondering if you have your 'Edit Access' set for the 'editor' group to be able to edit the site. It's sorta of a master switch for groups to be able to edit on a site wide level... using advanced permissions does not have this 'switch'. You can find these settings in dashboard/settings/set_permissions/
attached is a screen shot of my settings in a working install with the default base permissions.
The only thing that I did was check the box next to the 'Editor' group as it was un-checked by default.
Hope you get it working, good news is that, so far, the problem is isolated and, as far as I can tell, not with the package itself...
Hmmm, nope. That seems to be set up correctly. Screenshot attached.
So, I should probably add the advanced permissions to my site.php and see if that works, then?
So, I should probably add the advanced permissions to my site.php and see if that works, then?
Yeah, try that. I wish I could help but I can't seem to replicate the problem.
I can take look at your setup if you want just private message me.
I can take look at your setup if you want just private message me.
Thank you so much! Just what I needed!
One hint to anyone using this (I think I am right), if you wish to change the page it redirects to, you need to change line 27 in models\page_redirect_to_newest_child.php from:
to
by site map order
by name
One hint to anyone using this (I think I am right), if you wish to change the page it redirects to, you need to change line 27 in models\page_redirect_to_newest_child.php from:
$pl->sortByPublicDateDescending();
to
by site map order
$pl->sortByDisplayOrder();
by name
$pl->sortByName();
Thanks, your tip inspired me to take this addon little bit further.
Actually, it's technically a different addon, now called 'Page Auto Redirect' b/c you can select either the newest page, the first page in the site map, or a random page ( kinda fun, not sure if it's practical )
I'm attaching the package, I've tested with 5.5 works fine. Instead of installing a checkbox attribute it installs a select attribute for the selection.
Actually, it's technically a different addon, now called 'Page Auto Redirect' b/c you can select either the newest page, the first page in the site map, or a random page ( kinda fun, not sure if it's practical )
I'm attaching the package, I've tested with 5.5 works fine. Instead of installing a checkbox attribute it installs a select attribute for the selection.
Perfect. Thanks MrNiceGaius.
Nice stuff! Make sure you post this to the Marketplace, I'm sure others will find this useful as well.
Using Michael Krasnow's free 'Page Redirect' block, as a study reference, I've been able to create a package that installs a custom attribute 'Page Redirect To Newest Child' that when checked automatically redirects to the most recent child page. If no child page exists no redirect happens.
Just download the zip file... unzip into your packages directory... go to dashboard->add functionality , install the package.
Go to the page you want to redirect, add the newly created custom attribute 'Page Redirect To Newest Child' and make sure you check the box. At this point all requests to that page will be redirected to the newest child page. If you need to disable the redirect you must do so through the site map in the dashboard by accessing the page properties there.
Hope you like it,
Cheers,
Aaron
update: tested on c5 versions 5.4.1 & 5.4.2.1