Jump to content

Exception: Page is not currently viewable when using $page->children('include=all') and role cannot page-edit


SwimToWin
 Share

Recommended Posts

I have a nested page structure that fails for users without superuser permissions:

Works for superusers / non-superusers:
    - foo
    -- bar
    --- page (status: published)
    ---- page (status: published)
    --- page (status: published)

Fails for non-superusers (Works for superusers):
    - foo
    -- bar
    --- page (status: published)
    ---- page (status: published)
    --- page (status: unpublished <- apparently the template structure fails when there's one unpublished page)

Template:

    <?php foreach ($page->children('include=all') as $p): #Fails for non-superusers ?>
        <?=$p->render()?>
    <?php endforeach; ?>

    a) Works for non-superusers when I grant Page Edit permissions (on the template) to their assigned role/s.

    b) When I remove 'include=all' or 'include=unpublished' then it also works for non-superusers:

    <?php foreach ($page->children() as $p): #Works for non-superusers ?>
        <?=$p->render()?>
    <?php endforeach; ?>

Error message (non-superusers)
    Internal Server Error
        The server encountered an internal error or misconfiguration and was unable to complete your request.
        Error has been logged.

    /www/site/assets/logs/errors.txt
        /foo/bar/baz/    Error:     Exception: Page '/foo/bar/baz/quz/' is not currently viewable.

    /www/site/assets/logs/exceptions.txt
        /foo/bar/baz/    Page '/foo/bar/baz/quz/' is not currently viewable. (in /wire/modules/PageRender.module line 410)

Debug (non-superusers)

    Error: Exception: Page '/foo/bar/baz/quz/' is not currently viewable. (in wire/modules/PageRender.module line 410)

    #0 wire/core/Wire.php (397): PageRender->___renderPage(Object(HookEvent))
    #1 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array)
    #2 wire/core/Wire.php (465): WireHooks->runHooks(Object(PageRender), 'renderPage', Array)
    #3 wire/core/WireHooks.php (924): Wire->__call('renderPage', Array)
    #4 wire/core/Wire.php (465): WireHooks->runHooks(Object(Page), 'render', Array)
    #5 site/templates/template.php (191): Wire->__call('render', Array)

 

Link to comment
Share on other sites

// 'include=all' includes access restricted pages, check access via function viewable() before using render()
foreach ($page->children('include=all') as $p) {
    if ($p->viewable()) $p->render();
}

// without argument (selector) access restricted pages are excluded by default
foreach ($page->children() as $p) {
    $p->render();
}

Why do you want to render multiple pages?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...