Rodd Posted August 1, 2020 Share Posted August 1, 2020 Hi everyone, I'm not sure it's possible, but I'm asking. Maybe someone has a solution. Is it possible, when you want to create a template in the Processwire dashboard, to specify a template file from another folder which is different of the Template folder? In fact, I don't want to change the actual source which is the folder. I just want to find a way to recognize my templates which can be in a folder which is in the template folder, and use the find() function like this : <?php $childChildren = $pages->find("template=templatesWhichAreInTheSpecificFolder, sort=sort"); ?> I don't know if you understand my demand, but if you want more details, don't hesitate to ask. Thanks by advance! Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted August 1, 2020 Share Posted August 1, 2020 There is no easy way I know of to do exactly what you're asking for. But as far as I understand the actual need is to find pages with selected templates. If you do not need to select the templates to be used in selector in admin, you should be able to hard-code the selector like this (see here for explanation): <?php $childChildren = $pages->find("template=template-a|template-b|template-c, sort=sort"); If you need to be able to select the templates in admin, you could add this module to some page, and then use it's value in a selector. Hope the module still works in current version of PW. There is an option to tag fields in admin and then use the tag instead of a list of fields in selectors. If the same thing worked for templates, that could be a good way to solve this task. But I did not find any docs on that, so you just might want give it a try first, and then fallback to the module if it's not possible. 3 Link to comment Share on other sites More sharing options...
BillH Posted August 2, 2020 Share Posted August 2, 2020 The idea from @Ivan Gretsky of using template tags (which are on the Advanced tab of Edit Template) seems like a really good one. An approach to searching for tags on templates is here: Another possibility would be to prefix each relevant template name (e.g. "prefix-templatename") and then find using the "starts with" operator: $foundPages = $pages->find("template^=prefix"); But I think the tags approach would probably be better – more flexible, and organises things nicely on the Templates page in the admin. 3 Link to comment Share on other sites More sharing options...
Rodd Posted August 4, 2020 Author Share Posted August 4, 2020 Thanks @Ivan Gretsky and @BillH! I'm gonna use the first method with the templates. I see the interest about tags, but for my project, I have to use the templates 2 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