nico65 Posted December 18, 2016 Share Posted December 18, 2016 Hello I just saw, that you can render fields and repeaterblocks within their own templates. That's pretty Cool! I have a nested repeater block "gcb" that is rendered in: /site/templates/fields/gcb.php But this is just a switch, because in the repeater block is a selectfield, which tells the repeater block which sub field template it should use to render. E.g.: plain, spezialitaeten, tools These templates are all in the "gcb" subfolder: /site/templates/fields/gcb/plain.php /site/templates/fields/gcb/spezialitaeten.php /site/templates/fields/gcb/tools.php My Question now is, is there a easy solution to have a selectbox that lets you select between the file in the folder: /site/templates/fields/gcb/ Because right now, I have to update this selectfield manually, with the possible options. Link to comment Share on other sites More sharing options...
BitPoet Posted December 18, 2016 Share Posted December 18, 2016 You could use my FieldtypeDropdownDynamic in conjunction with a snippet of code that iterates the gcb directory for php files like the following (untested): return array_map( function($file) { return array("label" => $file, "name" => $file); }, array_filter( scandir($config->paths->templates . "gcb"), function($found) { return substr($found, -4) == ".php"; } ) ); 4 Link to comment Share on other sites More sharing options...
Macrura Posted December 18, 2016 Share Posted December 18, 2016 I sometimes use this module for selecting files: http://modules.processwire.com/modules/fieldtype-select-file/ 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