Get Preferences from a module [solved]

General project discussion. NOT for help questions.
Post Reply
andrewvideo
Forum Members
Forum Members
Posts: 127
Joined: Fri Nov 28, 2008 10:28 pm

Get Preferences from a module [solved]

Post 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
Last edited by andrewvideo on Thu Jun 02, 2011 10:46 pm, edited 1 time in total.
User avatar
myshko
Forum Members
Forum Members
Posts: 102
Joined: Wed Feb 07, 2007 2:36 pm

Re: I Get Preferences from a module made with CTLModuleMaker

Post 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
andrewvideo
Forum Members
Forum Members
Posts: 127
Joined: Fri Nov 28, 2008 10:28 pm

Re: I Get Preferences from a module made with CTLModuleMaker

Post 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
User avatar
myshko
Forum Members
Forum Members
Posts: 102
Joined: Wed Feb 07, 2007 2:36 pm

Re: I Get Preferences from a module made with CTLModuleMaker

Post 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
andrewvideo
Forum Members
Forum Members
Posts: 127
Joined: Fri Nov 28, 2008 10:28 pm

Re: I Get Preferences from a module made with CTLModuleMaker

Post by andrewvideo »

Thank you very much that did the job.

I want to read settings for my Module I made.

Thank you
User avatar
myshko
Forum Members
Forum Members
Posts: 102
Joined: Wed Feb 07, 2007 2:36 pm

Re: Get Preferences from a module [solved]

Post by myshko »

You're very welcome Andrew.

Glad it worked. Happy coding!

/m
Post Reply

Return to “General Discussion”