Page 1 of 1

[SOLVED] Add checkbox to contenttype (Cataloger)

Posted: Thu Jan 22, 2009 9:57 am
by flow24
Hi,

I’m trying to add an additional checkbox to the catalog-item-contenttype (Module Cataloger).
I already managed to let the box appear in the admin. The new prop is also stored in the database, but its value is not saved. Whenever I reedit the page the checkbox is off…

Here’s what I did:

I added this to SetProperties()

Code: Select all

$this->mProperties->Add('string', 'showOnFront', '');
Then I added this to the EditAsArray-Function under tab2:

Code: Select all

$ret[] = array('Show on Front Page','<input type="checkbox" name="showonfront"'.($this->showOnFront?' checked="checked"':'').' />');
Does anyone see what I’m missing??
Thanks for your help
 

Re: Add checkbox to contenttype (Cataloger)

Posted: Fri Jan 23, 2009 9:07 am
by flow24
Hi,

Does anyone have a hint on this one? I tried messing around with FillParams() as well but couldn’t really find out what does the trick.
However I think there’s only a minor tweak needed to make this work…

Help would be really appreciated! Regards!

Re: Add checkbox to contenttype (Cataloger)

Posted: Sat Jan 24, 2009 9:38 am
by flow24
Sorry, I know I’m anoying...
However, truth is I need to have that down on Monday, because my client’s website is supposed to be launched.

I’d really appreciate any little pointer into the right direction... :'(

Re: Add checkbox to contenttype (Cataloger)

Posted: Sun Jan 25, 2009 1:45 pm
by flow24
Ok, I spent hours on figuring this out. But I finally got it. I wanted to share this for everyone who has similar problems.

Change contenttype.catalogitem.php like this.

1. in setProperties() add

Code: Select all

$this->mProperties->Add('string', 'yourprop', '');
2. in editAsArray() add

Code: Select all

$ret[] = array(lang('yourprop'),'<input type="checkbox" name="yourprop"'.($this->GetPropertyValue('yourprop')?' checked="checked"':'').' />');
3. in FillParams() add

Code: Select all

if (isset($params['yourprop']))
{
     $this->SetPropertyValue('yourprop',1);
}
else
{
     $this->SetPropertyValue('yourprop',0);
}
4. you need to update the lang files in admin/lang/en_US or admin/lang/ext/YOUR-LANG like this

Code: Select all

$lang['admin']['yourprop'] = 'Your Property';
Hope this helps!