abmcr Posted September 27, 2017 Share Posted September 27, 2017 I have a strange behavior with the last PW 3.0.76 (debug mode on) ; i have created only 3 templates as you see in the first attachment, but in the settings tab of page i see, as possible template, my various repeater fields... This is a bug or i have broken some thing? Thank you in advance and apologize for english language, very poor Link to comment Share on other sites More sharing options...
louisstephens Posted September 27, 2017 Share Posted September 27, 2017 Im still trying to see if I can duplicate your issue on my end, but I do see that an issue was created in June regarding the same thing: https://github.com/processwire/processwire-issues/issues/287 However, it does not seem like Ryan could duplicate it either. Ill keep testing, though hopefully someone else will have an actual answer for you. 2 Link to comment Share on other sites More sharing options...
abmcr Posted September 27, 2017 Author Share Posted September 27, 2017 Link to comment Share on other sites More sharing options...
abmcr Posted September 27, 2017 Author Share Posted September 27, 2017 15 minutes ago, louisstephens said: Im still trying to see if I can duplicate your issue on my end, but I do see that an issue was created in June regarding the same thing: https://github.com/processwire/processwire-issues/issues/287 However, it does not seem like Ryan could duplicate it either. Ill keep testing, though hopefully someone else will have an actual answer for you. Thank you Link to comment Share on other sites More sharing options...
louisstephens Posted September 27, 2017 Share Posted September 27, 2017 It is very strange, on my 3.0.61 dev/testing site, I do have the repeaters showing up in the template select. I created a test_repeater for this, and as You can see, it is displaying at the bottom of the list in my screenshot. I have $config->advanced = false; (what Ryan was asking in the github issue), and to be honest I am pretty confused as to why this is showing up. Does anyone else have this occurring in a dev setup or a live? Note: test_repeater has 5 items added to it (used on 1 template, but the specials repeat has 4 items , but is being used on multiple pages (I guess where the duplication comes from). Link to comment Share on other sites More sharing options...
abdus Posted September 27, 2017 Share Posted September 27, 2017 Repeater templates are set to have no parents // FieldtypeRepeater.module /** * Populate the settings for a newly created repeater template * @param Template $template */ protected function populateRepeaterTemplateSettings(Template $template) { $template->flags = Template::flagSystem; $template->noChildren = 1; $template->noParents = 1; // prevents users from creating pages with this template, but not us $template->noGlobal = 1; } which should be enough to keep them off of ProcessPageEdit (page edit screen, template option at settings tab) /** * Returns an array of templates that are allowed to be used here * @return array|Template[] Array of Template objects */ protected function getAllowedTemplates() { // ... foreach($allTemplates as $template) { // ... } else if($template->noParents) { // user can't change to a template that has been specified as no more instances allowed // except for superuser... we'll let them do it continue; } // ... } return $templates; } and ProcessPageAdd (new page screen) protected function ___getAllowedTemplates($parent = null) { // ... foreach($allTemplates as $t) { // ... } else if($t->noParents) { continue; } // ... $templates[$t->id] = $t; } // ... return $templates; } But seeing how they still show up, I'm guessing somehow $noParents is corrupted to a falsy value. Checking the DB, you shouldn't have noParents entry in templates table for repeater templates. Otherwise I'm not sure how it's possible at all. Link to comment Share on other sites More sharing options...
abdus Posted September 27, 2017 Share Posted September 27, 2017 Hmm. One thing I missed is that ProcessPageEdit allows super users to pick any template // ProcessPageEdit.module protected function getAllowedTemplates() { // ... foreach($allTemplates as $template) { // ... if($isSuperuser) { $templates[$template->id] = $template; } else if($template->noParents == -1) { // only one of these is allowed to exist if($template->getNumPages() > 0) continue; } else if($template->noParents) { // user can't change to a template that has been specified as no more instances allowed // except for superuser... we'll let them do it continue; // ... } // ... return $templates; } I dont think picking repeater templates should be allowed. if block shouldn't start with checking superuser, but it should come after. This order should stop repeater templates from showing. if($template->noParents == -1) { // only one of these is allowed to exist if($template->getNumPages() > 0) continue; } else if($template->noParents) { // user can't change to a template that has been specified as no more instances allowed // except for superuser... we'll let them do it continue; } elseif($isSuperuser) { $templates[$template->id] = $template; } Can someone confirm changing the order (ProcessPageEdit.module, at line 1973) fixes the issue? 3 Link to comment Share on other sites More sharing options...
matjazp Posted September 28, 2017 Share Posted September 28, 2017 6 hours ago, abdus said: Can someone confirm the changing the order (ProcessPageEdit.module, at line 1973) fixes the issue? Confirm. Link to comment Share on other sites More sharing options...
abmcr Posted September 28, 2017 Author Share Posted September 28, 2017 8 hours ago, abdus said: Hmm. One thing I missed is that ProcessPageEdit allows super users to pick any template // ProcessPageEdit.module protected function getAllowedTemplates() { // ... foreach($allTemplates as $template) { // ... if($isSuperuser) { $templates[$template->id] = $template; } else if($template->noParents == -1) { // only one of these is allowed to exist if($template->getNumPages() > 0) continue; } else if($template->noParents) { // user can't change to a template that has been specified as no more instances allowed // except for superuser... we'll let them do it continue; // ... } // ... return $templates; } I dont think picking repeater templates should be allowed. if block shouldn't start with checking superuser, but it should come after. This order should stop repeater templates from showing. if($template->noParents == -1) { // only one of these is allowed to exist if($template->getNumPages() > 0) continue; } else if($template->noParents) { // user can't change to a template that has been specified as no more instances allowed // except for superuser... we'll let them do it continue; } elseif($isSuperuser) { $templates[$template->id] = $template; } Can someone confirm changing the order (ProcessPageEdit.module, at line 1973) fixes the issue? Yes this fixes the issue. Thank you very mutch Link to comment Share on other sites More sharing options...
abdus Posted September 28, 2017 Share Posted September 28, 2017 I created an issue https://github.com/processwire/processwire-issues/issues/388 3 Link to comment Share on other sites More sharing options...
Beate Posted September 28, 2017 Share Posted September 28, 2017 Fixed it for me, too. Thanks. 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