Page Forbidden not displaying blocks.

Permalink
Hi All

I posted this within someone else's post but go no response so thought I would create a new one….

I have created a custom 'page forbidden' and changed the config/site_theme_paths.php accordingly. However, when a user is not logged into the site, and tries to access a page for which they must be logged in, they are taken to a page that doesn't have all the blocks that I added?!?

e.g.

http://www.ecossedirect.com/newsite/login......
http://www.ecossedirect.com/newsite/dashboard......

I have tried this of a few C5 sites and have the same problem.

Set permissions on a page so guests can not view it... when the user does try to go to that page it just displays my custom template with the login form and does not pull in any of the blocks I added to the page.

I know that altering the view.php page in themes/ directory has an effect on the erroneous login pages, however, for these problem login pages to look as expected, either the single_pages/login.php or themes/xxx/view.php would have to have the blocks required to be displayed hardcoded, which isn't ideal.

Any fixes that don't require hardcoding would be much appreciated.

Cheers

Iona and Chris

senshidigital
 
Mainio replied on at Permalink Reply
Mainio
Hi,

I THINK the reason why your custom blocks do not display properly is that the custom blocks are page specific. This means that e.g. this page:
http://www.ecossedirect.com/newsite/login...

is different from this one:
http://www.ecossedirect.com/newsite/dashboard...

So, for logging in you should probably setup a custom redirect all pages that start with /dashboard/ so that if people are accessing those pages, they are redirected to:
http://www.ecossedirect.com/newsite/login...


You can even tell the login controller where to redirect your users after login like this:
http://www.ecossedirect.com/newsite/login/forward/123...

And in that URL the 123 is the collection ID (cID) of the page where you want to redirect to.

Br,
Antti / Mainio
senshidigital replied on at Permalink Reply
senshidigital
Thanks for this. We did place the blocks on the page forbidden page but did not work.
Mainio replied on at Permalink Reply
Mainio
Yes, page_forbidden is a template, e.g. /login/ and /dashboard/ are pages using that template when not logged in. Still, for both of these pages, the content might differ although they were using the same template.

EDIT: Actually /login/ is its own single page, that was a bad example.

So, I'd still just suggest redirecting (I think it's the easiest way to go). However, you could also setup a custom scrapbook for pulling the content into these pages when you wouldn't have to worry about which page is using the page_forbidden template.

Antti / Mainio
senshidigital replied on at Permalink Reply
senshidigital
Cheers for that, although it's not just the /dashboard that redirects to this odd login page. It is any page that a user needs to be logged in to view, so for example, the members page too:

http://www.ecossedirect.com/newsite/members...

etc...

We would rather have this login page pull in the blocks correctly rather than setting up multiple redirects.
Mainio replied on at Permalink Reply
Mainio
Yes, I understand but you actually wound't have to setup such many redirects. You could e.g. setup a custom package for your need that would do the redirection automatically.

The code for this is basically something like this:
// TODO: Find out current collection and save it in $c 
$cp = new Permissions($c);
if ($cp->isError() && $cp->getError() === COLLECTION_FORBIDDEN) {
   $target = Page::getByPath('/login');
   if ($c->getCollectionID() !== $target->getCollectionID()) {
      Controller::redirect('/login/forward/' . $c->getCollectionID());
   }
}



The code above is just a dummy version and probably there are few more things to think about when doing it really but that's the basic procedure. No custom redirection, it's just a common solution when the user does not have permissions for the page.

This can be run e.g. in package's on_start() function BUT when that function runs, the global $c variable is not yet available. However, it is possible to run there.


Br,
Antti / Mainio
cyandesigns replied on at Permalink Reply
Hey Dojo

Did you ever figure this out simply?

Would LOVE to know how to get this working properly, quickly and easily!

Thanks!
senshidigital replied on at Permalink Reply
senshidigital
Afraid not. Not sure if its solved in 5.5 but does not work properly the 5.4.
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
It is not solved in 5.5.2.1 either, I have the same problem :(
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I'm also facing the same problem & I'm using Concrete5 v5.6.1.2

Rony