Page 1 of 1
Get Preferences from a module [solved]
Posted: Wed Jun 01, 2011 11:51 pm
by andrewvideo
Hi People
I call Preferences from a module made with CTLModuleMaker 2.0.3
For example I want to call a setting for somepref in my templace
I tried
{$this->GetPreference('somepref')} and got a error
{$this->GetPreference->somepref} not worked.
I would like show the valuable in my template and do a If valuable not blank print some text.
Sorry about my english. Hope someone can help.
Cheers
Re: I Get Preferences from a module made with CTLModuleMaker
Posted: Thu Jun 02, 2011 1:08 am
by myshko
Hi Andrew,
I think this is what you want:
Code: Select all
{if $item->prefName != ''}
{$item->prefName}
{else}
Pref Name Empty
{/if}
Where 'prefName' is the name of the module variable you wish to call.
You can also do it like this:
Code: Select all
{if isset($item->prefName)}
{$item->prefName}
{else}
Pref Name Empty
{/if}
/m
Re: I Get Preferences from a module made with CTLModuleMaker
Posted: Thu Jun 02, 2011 9:46 am
by andrewvideo
Hi,
That dint work. I think that is only for the item entry.
I think there is a tag for it so you can all call any Preferences from any module.
I can see the entry in the sitepref in the datebase i want get the value.
Do anyone know how to do this?
Cheeers
Re: I Get Preferences from a module made with CTLModuleMaker
Posted: Thu Jun 02, 2011 6:38 pm
by myshko
Hi,
I think you need to make a User Defined Tag to get those values (as opposed to calling them directly with smarty).
Perhaps:
Code: Select all
global $gCms;
$prefName = get_site_preference('prefName');
return $prefName;
As a user defined tag might work.
What's the specific preference you are after?
/m
Re: I Get Preferences from a module made with CTLModuleMaker
Posted: Thu Jun 02, 2011 10:45 pm
by andrewvideo
Thank you very much that did the job.
I want to read settings for my Module I made.
Thank you
Re: Get Preferences from a module [solved]
Posted: Thu Jun 02, 2011 10:53 pm
by myshko
You're very welcome Andrew.
Glad it worked. Happy coding!
/m