Page 1 of 1

[solved] ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:02 am
by Cerulean
I'm considering using ListIt2 together with FormBuilder to allow ListIt2 items to be created from a form on the frontend. (Thanks goes out to the tutorial: http://www.i-do-this.com/blog/FormBuild ... xtended/57)

I'll need these items submitted from the frontend to be moderated by an administrator before they appear on the live site, and it seems that the active/inactive setting that is built into every ListIt2 item would be ideal for hiding items awaiting moderation. The only thing is that new items seem to be set active by default. Is there a way to have new items set inactive by default?

Re: ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:15 am
by uniqu3
How about adding following to UDT:

Code: Select all

$obj->title = $params['email'];
$obj->alias = $alias;
$obj->active = 0; // <- add this, item disabled by default

Re: ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:18 am
by Cerulean
Obvious now that you mention it :-)
Thanks.

Re: ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:27 am
by velden
You could have a look at the events in Event Manager.

It has e.g.: PreItemSave "Sent before item save process begins. Possible to manipulate item object data."

It would probably need some debugging to find the proper properties that need to be set. And a way to prevent it from being set inactive on every save (which would make the item unusable of course).


EDIT: never mind, better listen to uniqu3

Re: [solved] ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:35 am
by Cerulean
@velden
Thanks for the suggestion, but I think uniqu3 has hit upon the easiest way.

The ListIt2 field values are copied over from the FormBuilder fields by the UDT (see the tutorial I linked to above if you're curious), so it's easy to set the "active" value to 0 at the same time. Overwriting the active/inactive state of an already moderated item isn't an issue because every form submission creates a new ListIt2 item (and in my case I don't need to allow frontend users to edit their previously submitted forms).

Re: [solved] ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:53 am
by nikkio
Just a little trick...

with the latest version of FormBuilder, you can populate a Listit2 instance ad set the active/inactive status of the item.

You can do it by choosing "*Store Results for ListItExtended" as field type and defining the instance you want to populate. ;)

Re: [solved] ListIt2 - set new items inactive by default?

Posted: Wed Feb 12, 2014 8:56 am
by uniqu3
Latest Version 0.7.4 has bugs and should not be used, see http://forum.cmsmadesimple.org/viewtopi ... =7&t=67867.