adrian Posted December 8, 2016 Share Posted December 8, 2016 Hi everyone! Just curious if anyone has developed a solution for this. I feel like it has been mentioned somewhere before, but I am not finding anything. I have a site with a complex, but repetitive tree (hence my various branch restriction modules), and I am finding myself wanting the ability to add a field but only have it available on a specific branch. I obviously don't want a separate template for this one field so I am thinking of creating something to make this possible, but just want to make sure I am not reinventing the wheel. It might be best to just go with a simple hook that is specific to this scenario, but maybe this is also an opportunity to build something that makes it easier to manage these situations through the field's settings. At first thought I am thinking of a new "Branch Restrictions" tab (between Access and Advanced) on the field settings page that lets you limit what pages it will appear on. Any thoughts? Link to comment Share on other sites More sharing options...
Robin S Posted December 8, 2016 Share Posted December 8, 2016 Hi Adrian, I have a module that could be helpful here - just putting the finishing touches on it and will release this weekend. Cheers, Robin. 9 Link to comment Share on other sites More sharing options...
adrian Posted December 8, 2016 Author Share Posted December 8, 2016 Now that's what I call service, or maybe it's just "Great minds think alike" Can't wait to see what you have put together! 4 Link to comment Share on other sites More sharing options...
adrian Posted December 10, 2016 Author Share Posted December 10, 2016 Hey @Robin S - obviously I don't know what approach you have taken so far, but I just had another idea for how this could be implemented. Perhaps under the field's Input > Visibility > ShowIf settings, there could be new options: 1) a selector text field, 2) a custom PHP code textarea. This would be a little like the Input > Selectable Pages options for Page fields. Anyway, I think this could be really powerful - if the currently edited page doesn't match the selector, or the custom php doesn't return true, the field would be hidden completely from the page editor for that page. What do you think ? 2 Link to comment Share on other sites More sharing options...
Robin S Posted December 10, 2016 Share Posted December 10, 2016 Hi Adrian, My Custom Inputfield Dependencies module is released and the forum thread is here. Not a very precise module name - I struggled with it. 2 hours ago, adrian said: Perhaps under the field's Input > Visibility > ShowIf settings, there could be new options: 1) a selector text field, 2) a custom PHP code textarea. This would be a little like the Input > Selectable Pages options for Page fields. You'll see that the effect of my module is similar to what you propose above, but using what is available in the core (and Hanna Code) now. But I think it would be cool to have new features added to the core to allow this directly in field settings like you propose, so if you want to make a Github request I'll gladly add my +1. Hopefully you can use Custom Inputfield Dependencies for what you had in mind in this thread's original post. 1 Link to comment Share on other sites More sharing options...
adrian Posted December 10, 2016 Author Share Posted December 10, 2016 I haven't tested your new module yet - I am sure it will work great But back to the thoughts from my last post, I was thinking of hooking into: Inputfield::getConfigInputfields and adding the selector and custom php options there. Anyway, when I have a minute I'll try your module and also take a look at that hook and see if I can implement it that way as well. 1 Link to comment Share on other sites More sharing options...
Robin S Posted December 10, 2016 Share Posted December 10, 2016 3 hours ago, adrian said: But back to the thoughts from my last post, I was thinking of hooking into: Inputfield::getConfigInputfields and adding the selector and custom php options there. Ahh, good idea! 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