JayGee Posted October 21, 2019 Share Posted October 21, 2019 Pretty much as per the topic subject - trying to figure out how to toggle a repeater on/off using the API. Have tried setting the page status which indeed seems to hide the item but this doesn't reflect the toggle on the page editor so when you next save the page they come back on. Link to comment Share on other sites More sharing options...
Zeka Posted October 21, 2019 Share Posted October 21, 2019 @Guy Incognito AFAICS, this functionality relies on cookies. There is'repeaters_open' cookie which holds ID's of opened items. So, probably you can try to use https://processwire.com/api/ref/wire-input/cookie/ in hook to manipulates it. Link to comment Share on other sites More sharing options...
adrian Posted October 21, 2019 Share Posted October 21, 2019 By toggle off, I assume you mean "unpublish"? It's possible, but it's a real mess. However if you read through this: https://github.com/processwire/processwire-issues/issues/36 you'll be able to get it working. 3 Link to comment Share on other sites More sharing options...
JayGee Posted October 25, 2019 Author Share Posted October 25, 2019 On 10/21/2019 at 4:51 PM, adrian said: By toggle off, I assume you mean "unpublish"? It's possible, but it's a real mess. However if you read through this: https://github.com/processwire/processwire-issues/issues/36 you'll be able to get it working. Thanks all - that does all seem a bit of a headache - it's not mission critical so will probably just stick with deleting unused items rather than disabling them or just let the user manually manage them. Had naively assumed that as repeater items were pages behind the scenes that the 'toggle' would just be a proxy for unpublishing them or something similar. Link to comment Share on other sites More sharing options...
adrian Posted October 25, 2019 Share Posted October 25, 2019 6 minutes ago, Guy Incognito said: Thanks all - that does all seem a bit of a headache - it's not mission critical so will probably just stick with deleting unused items rather than disabling them or just let the user manually manage them. Had naively assumed that as repeater items were pages behind the scenes that the 'toggle' would just be a proxy for unpublishing them or something similar. They are just pages behind the scenes and unpublishing would work if Ryan would fix the 2048 vs 2049 issue, although I guess at this point it might be a breaking change. Did you try: $item->addStatus(Page::statusUnpublished); $item->removeStatus(Page::statusOn); Link to comment Share on other sites More sharing options...
JayGee Posted October 25, 2019 Author Share Posted October 25, 2019 5 minutes ago, adrian said: Did you try: $item->addStatus(Page::statusUnpublished); $item->removeStatus(Page::statusOn); I think I did - but will double check as got frustrated and parked it for later on lol! I think it was causing strange things like the item still showing in the repeater without affecting the on/off toggle and then re-enabling when the parent page was saved. Will give it another go and report back. 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