Jump to content

Disallow accessing page using template via it's url


LimeWub
 Share

Recommended Posts

Hey,

I am using a block-like structure for a website I'm building, in which a page can be created using many building block "pages".

For example

- Page
  - slideshow block ("Page")
  - content block ("Page")

On render, Page gets all it's children blocks and renders them. Everything with this approach works great, however, I have one issue...

 

Issue:

Block templates have a template file (to render with). This makes them accessible by url. 

For example: website.com/page/slideshow-block is a (very ugly) page on the site atm.

 

Question:

Is there any way to block certain templates from being accessed by their url?

Seems like something that should be feasible but I just can't find the setting/way to do it...

 

Thanks :)

Link to comment
Share on other sites

Hey @LimeWub, I found a soultion to your question. If you go to the template being used by slideshow and navigate to the "Access" tab, you can achieve what you are after. In my case (for the test), I simply unchecked view pages for guest, and selected "Redirect to another URL" which allowed me to keep the page from being accessed by someone not already logged in with the proper credentials.

 

Screen Shot 2017-01-17 at 12.25.07 PM.png

  • Like 3
Link to comment
Share on other sites

There's a couple of approaches

  1. Unpublish you block pages: You will still be access them via the API with include=all in your -Page template. You would have to handle 404s in this case
  2. Redirect: Redirect access to block pages to -Page. SEO issues?
  3. Etc...(I've gone totally blank but there should be another strategy, I think :-X:))
  • Like 2
Link to comment
Share on other sites

A couple more options...

At the top of the file for the template of pages you are including inside another page:

if(empty($options['pageStack'])) throw new Wire404Exception();
if($page->url == $_SERVER['REQUEST_URI']) throw new Wire404Exception();

A related thread:

 

  • Like 4
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...