John W. Posted September 18, 2019 Share Posted September 18, 2019 Hi, I've set up a structure like so: these are the templates documents -> documents_category -> documents_document Basically, when someone goes to /documents/ it creates a listbox of categories and the page then lists all the documents_document in that documents_category. In my listbox, I have the url value set to /documents/document_category for instance /documents/human-resources/ would list all the documents contained under human-resource. Herein is the problem, I just want to use the human-resources as a url parameter to pass to /documents/ rather than processwire trying to load an actual page at /documents/human-resources/documentname Right now, it goes to /documents/human-resources/documentname/ Is there a way to set processwire to treat human-resources as a url parameter and not attempt to load the child page /documentname/? Note, I added a path like /documents/results/document-category/ which works, however, I need this to work in the back-end when using a page select field. The only solution I could think of was creating a documents_category.php file that takes the url, /documents/document-category/ and changes it to /documents/results/document-category/ then does a session redirect. Using this a page select would go to /documents/document/category/ which inserts the "/results/" segment and then redirects to /documents/results/category-name Thanks! Link to comment Share on other sites More sharing options...
Sergio Posted September 18, 2019 Share Posted September 18, 2019 /documents/human-resources/ is a page accessible because it has a template file and is published. If you set, to its children, a template that does not have a template file (.php), they will not be accessible directly. So you can use the API to get their content and show to the user. So: /documents/human-resources/ works /documents/human-resources/document-name will get a 404 1 Link to comment Share on other sites More sharing options...
John W. Posted September 18, 2019 Author Share Posted September 18, 2019 Yeah, I understand that. I had to create a page for the document-name, simple php file that redirects to documents/results/human-resources/ my documents.php then pulls the 3rd url segment and uses that for my $pages-find() query to filter results It works. Just figured there might be another way. Link to comment Share on other sites More sharing options...
Sergio Posted September 18, 2019 Share Posted September 18, 2019 2 hours ago, John W. said: Yeah, I understand that. I had to create a page for the document-name, simple php file that redirects to documents/results/human-resources/ Actually is the other way around, the document template should NOT have a PHP file. So on the Human Resource page, you can loop though its children and display the info you need. I guess is the document title, link to download etc. Link to comment Share on other sites More sharing options...
John W. Posted September 19, 2019 Author Share Posted September 19, 2019 Yup, that is what I'm doing. However, the trouble is I'm using a Page Reference field in another template, which creates a link like /documents/document-category/nameofdocument Of course, it throws a 404, since "nameofdocument" doesn't exist. So, what I did, for "nameofdocument", I created a php file for that template that redirects to /documents/results/document-category/. Since /documents/results/ doesn't have a template it just treats results/ like a url segment. ? Link to comment Share on other sites More sharing options...
adrian Posted September 19, 2019 Share Posted September 19, 2019 5 hours ago, John W. said: my documents.php then pulls the 3rd url segment and uses that for my $pages-find() query to filter results So the $pages->find finds the page in the 3rd url segment and displays the content of that page? I guess I don't understand why that is better than having a template file for the document template - I am sure I am missing something, but maybe if you could better explain what you are actually trying to accomplish by doing it this way we might be able to offer some other/better alternatives. 1 Link to comment Share on other sites More sharing options...
John W. Posted September 21, 2019 Author Share Posted September 21, 2019 On 9/18/2019 at 9:48 PM, adrian said: So the $pages->find finds the page in the 3rd url segment and displays the content of that page? I guess I don't understand why that is better than having a template file for the document template I don't have a php template for documents. The non-php template, for documents just holds a title, summary and has pdf attachments available for download. Therefor, when /documents/ does a query, it finds all the "document" templates and lists them with a title, summary, and links to either view or download a pdf. See this screenshot: /documents/ simply does a list like this where visitors can see a date, title, summary and download or view pdf files. the information for each entry is a php-less template with date, title, summary and a file-type pdf field for attaching the pdf. Link to comment Share on other sites More sharing options...
adrian Posted September 21, 2019 Share Posted September 21, 2019 @John W. - I understand the way the documents template works - to load a summary list of documents, but I still don't understand the problem with PW trying to load the individual document when the document is in the URL - how do users end up with the document component in the URL and what are they supposed to see when it is? 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