[opgelost] formbuilder to list sinds CMSMS 2.x

Nederlandse ondersteuning voor CMS Made Simple

Moderator: velden

Post Reply
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

[opgelost] formbuilder to list sinds CMSMS 2.x

Post by pedes »

In vorige versies van CMSMS gebruikte ik een UDT om de ingave van een formbuilder form op te slaan in een ListIt2 instantie .
Dit werkte perfect!

Sinds de komst van CMSMS 2.x kan je ListIt2 niet meer gebruiken en gebruik ik Easylist (some ook al LISE), maar daar werkt de voormalige UDT niet meer.
Iemand die weet hoe ik de UDT aanpas zodat deze ook werkt voor Easylist en het nieuwe LISE.

Dit is de gebruikte UDT

Code: Select all

/**
 * Load wanted ListItExtended instance, where you wan't to save items.
 * If instance can't be loaded, it will silently return.
 */
$mod = cmsms()->GetModuleInstance('ListIt2instantienaam');
if(!is_object($mod))
    return;
 
/**
 * Intitate empty item using API.
 */    
$obj = $mod->InitiateItem();
/**
 * Fill previously initiated ListIt2Item object with values from form submission.
 * NOTICE: All params that are not known by ListIt2Item object are going to ignored.
 */        
$obj->title = $params['email'];
 
foreach($params as $key => $value) {
    if(isset($obj->fielddefs[$key]))
        $obj->$key = $value;
}
 
/**
 * Save this object to database by using ListItExtended API.
 */        
$mod->SaveItem($obj);
Alvast dank voor de hulp,
Grtz
Peter
Last edited by pedes on Thu Feb 25, 2016 4:32 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: formbuilder to list sinds CMSMS 2.x

Post by Jo Morg »

There is just a minor adjustment needed in the UDT in order for it to work with LISE instances:

Code: Select all

/**
 * Load wanted ListItExtended instance, where you wan't to save items.
 * If instance can't be loaded, it will silently return.
 */
$mod = cmsms()->GetModuleInstance('ListIt2instantienaam'); //<-- this needs to change to the real instance name, probably LISE<instance_name>...
if(!is_object($mod))
    return;
 
/**
 * Intitate empty item using API.
 */    
$obj = $mod->InitiateItem();
/**
 * Fill previously initiated ListIt2Item object with values from form submission.
 * NOTICE: All params that are not known by ListIt2Item object are going to ignored.
 */        
$obj->title = $params['email'];
 
foreach($params as $key => $value) {
    if(isset($obj->fielddefs[$key]))
        $obj->$key = $value;
}
 
/**
 * Save this object to database by using ListItExtended API.
 */        
$mod->SaveItem($obj);
Other than that the API is the same...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: formbuilder to list sinds CMSMS 2.x

Post by pedes »

Hi Jo Morg,

Thank you for your reply, I had the instance name ok, but I missed the email field, that was mentioned in the UDT. So this is working... but

As this is a form for putting a comment in a review list, I would like to put the status off the in input standard off or not actif.
Normal this is standard on active.

Is there a way to put this in the UDT or in some other way.
So that I can decide if the input can be active and viewed on the website?

Kind regards
Peter
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: formbuilder to list sinds CMSMS 2.x

Post by Jo Morg »

I didn't test it but try:

Code: Select all

$obj->active = FALSE;
... just before the "$mod->SaveItem($obj);". It should work...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: formbuilder to list sinds CMSMS 2.x

Post by pedes »

Nice, very nice...
Thank you Jo Morg for your solution .

I can recomment this UDT to all who is using LISE or previous fork of this module.

Kind regards
Post Reply

Return to “Dutch - Nederlands”