I have created an archive page within my theme. The content displays as expected unless I add my {{#if access}} controls to ensure the page access control settings are applied from the page settings in the dashboard.
Configuring my dynamic routing with controller: channel is what breaks my page. Does this make the page ignore my template or ignore the data page? How can I use dynamic routing channel and still have the ability to use the data page’s access control settings?
My routes.yaml is configured as:
routes:
/archive/:
data: page.archive
template: archive
controller: channel
collections:
/:
permalink: /{slug}/
template: index
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
(This is a continuation of this thread, right? Custom page access configuration - #10 by quillofphil )
OK, so I think I’m confused. Are you trying to pull the access info from the page (archive, created in the page editor), or are you trying to check access of individual posts as you loop over them?
I want to set the page access in the page editor. Then I want my template to verify access and either show the content, or the call to action depending on the user’s access level. It works perfectly when doing foreach on posts with normal routing, but the code I am trying to use to pull the posts and make them look nice with pagination requires using a dynamic routing channel. Updating the routes.yaml to use the channel then breaks everything.
I cannot call the {{#post}} tag in my page at that point which is required to use the {{#if access}} tag.
Why not?
I’m not sure it’ll work, but it might also be worth trying {{#if page.access}} or {{#if post.access}} [Yes, sometimes I have to play with it to get it to work…]
That did it.
{{#if page.access}} works. I had tried {{#if post.access}} because of a post I read and gave up on that path. I did not know that the if helper could be modified with post or page context. The docs for IF do not mention it:
1 Like
That dot notation (and also …/ to move up a level) are not super well documented but you definitely need them sometimes! :)
1 Like