Jump to content
Guy Incognito

Can I toggle a repeater item on/off with API?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...