[SOLVED] Add checkbox to contenttype (Cataloger)

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
flow24
Forum Members
Forum Members
Posts: 28
Joined: Tue Apr 22, 2008 2:46 pm

[SOLVED] Add checkbox to contenttype (Cataloger)

Post 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
 
Last edited by flow24 on Sun Jan 25, 2009 1:46 pm, edited 1 time in total.
flow24
Forum Members
Forum Members
Posts: 28
Joined: Tue Apr 22, 2008 2:46 pm

Re: Add checkbox to contenttype (Cataloger)

Post 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!
flow24
Forum Members
Forum Members
Posts: 28
Joined: Tue Apr 22, 2008 2:46 pm

Re: Add checkbox to contenttype (Cataloger)

Post 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... :'(
flow24
Forum Members
Forum Members
Posts: 28
Joined: Tue Apr 22, 2008 2:46 pm

Re: Add checkbox to contenttype (Cataloger)

Post 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!
Post Reply

Return to “Modules/Add-Ons”