robobobo Posted January 28, 2015 Share Posted January 28, 2015 Hello, i tried to include subpages in a parent page... The subpages should not be shown/accessible to any users especially for guests... I built a page tree and some templates with user rights like this: - Home -- Page (template -> access to all users + template-file: press-overview.php) --- SubPage1(template-access: no access to guest + template-file: press-article.php) --- SubPage2(template-access -> no access to guest + template-file: press-article.php) --- SubPage3(template-access -> no access to guest + template-file: press-article.php) --- SubPage....(template-access -> no access to guest + template-file: press-article.php) Then I wrote something like this to include the pages in the press-overview.php: foreach ($page->children( template=press-article') as $child) { $out .= $child->render(array('included'=>true)); // note: if there is no $option['included'] in the child-page then redirect... } ... this way the content of the subpages isn't shown in the parent page for guest users ... in the frontend. Is there a way to show pages 'included' by the 'page render function' even though the current users have no page-view-access to them" I want to exclude these pages e.g. for sitemap.xml... To hide the pages in the page tree is not an option! Thanks in advance... Robert Link to comment Share on other sites More sharing options...
robobobo Posted January 29, 2015 Author Share Posted January 29, 2015 I found a very simple solution! foreach ($page->children('template=press-article, check_access=0') as $child) { $out .= $child->render(array('included'=>true)); } It is quite simple: the solution is check_access=0 PW seems to have the right answer to any question! Thanks for PW! Link to comment Share on other sites More sharing options...
Soma Posted January 30, 2015 Share Posted January 30, 2015 You don't need to remove view access at all. Just don't create a php file for the subpage template so it will not be directly viewable. So you dont need to turn access control off and can also search without adding that etc. Link to comment Share on other sites More sharing options...
Soma Posted January 30, 2015 Share Posted January 30, 2015 Access right is used for restricting pages for logged in users etc. I would avoid that solution in this case. Link to comment Share on other sites More sharing options...
robobobo Posted January 30, 2015 Author Share Posted January 30, 2015 Hi Soma, thanks for your reply. I know about the option 'template without templatefile' but in this case i can't use the render function, isn't it? Would it be better to write my own function to render the subpages and include it, or generate the output directly on the parent page? Please help me to find a passable way to handle it. Link to comment Share on other sites More sharing options...
Soma Posted January 30, 2015 Share Posted January 30, 2015 Sure, specify a template file in the render method $out .= $child->render("yoursubtemplate.php", array('included'=>true)); Or just your template but handle the "when directly viewed" and throw a 4040 In your subpage-template if(!count($options['pageStack'])) { // not rendered from other page, pageStack will be empty throw new Wire404Exception(); } ... render output Or if(!isset($options['included'])) { // not rendered from other page,"included" won't exist throw new Wire404Exception(); } ... render output Link to comment Share on other sites More sharing options...
robobobo Posted January 30, 2015 Author Share Posted January 30, 2015 Oh, thanks... i have already done this (thats not the problem): $out .= $child->render(array('included'=>true)); // note: if there is no $option['included'] in the child-page then redirect... and checkt for $option['included'] in the sub-templatefile... I think i know what you mean: the solution is not to combine the template with the templatefile and then make a reference by parameter in the render function: $out .= $child->render("press-article.php", array('included'=>true)); My mistake is, that i associate the template with the templatefile in the PW-Backend. Thanks for your input! Link to comment Share on other sites More sharing options...
robobobo Posted January 30, 2015 Author Share Posted January 30, 2015 Another question: how can i remove the association between a template and an templatfile, if it already exists?? Sorry for this newbie questions... Link to comment Share on other sites More sharing options...
robobobo Posted January 30, 2015 Author Share Posted January 30, 2015 Please ignore my last post, i renamed the templatefile on the server and everything is ok. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now