Page 1 of 1

New Module Custom Global Settings

Posted: Sun Feb 19, 2012 12:56 pm
by Rolf
The Custom Global Settings module extends the Global Settings with some customized parameters. You can define an unlimited number of fields which can be used as smarty-variable in templates or pages.

The initial module (with limited options) was created by me, but *Gallery* Jos will continue the development of this module! Jos already added some new features, making it a very flexible and versatile module.

In the Custom Global Settings module Fielddefinitions tab you can define several field definitions. In the templates or pages of your website you will have all smarty variables available!
The exact way to call each variable is shown in the fielddefinitions table. You can also check which variables and values are available by placing {CustomGS showvars=1} in the content field of a page.

Available fielddefinitions
- Textfield
- Pulldown
- Checkbox
- Radiobutton group
- Datepicker
- DateTimepicker
- Timepicker
- Text Area
- WYSIWYG Area
- Button

Some examples
Start with adding the moduletag in the top of your template

Code: Select all

{CustomGS}
Define a checkbox 'Christmas now' which will activate a special theme on the frontend when checked.

Code: Select all

{if $CustomGS.Christmas_now == '1'}
     {* Show Christmas frontend theme *}
{else}
     {* Show default frontend theme *}
{/if}
Define a checkbox 'MyCheckbox' which will do some magic stuff when unchecked

Code: Select all

{if $CustomGS.MyCheckbox != '1'}
     {* Do some magic stuff *}
{/if}
Define a textfield or pulldown field 'Trainer' which will contain the current trainers name.

Code: Select all

<p>This weeks trainers name is: {$CustomGS.Trainer}</p>
Define two timepicker fields 'starttime' and 'endtime'. Replace the {content} tag in your page template with this code and the normal page content is only visible when the current time is between the starttime and endtime.

Code: Select all

{if $smarty.now|date_format:'%H:%M' >= $CustomGS.starttime && $smarty.now|date_format:'%H:%M' <= $CustomGS.endtime}
     {content}
{else}
     {content block="SiteClosedContent"}
{/if}
Upgrading? The way smarty variables should be called has changed. If you upgrade from 1.0 you have to rename the smarty variables in your templates or pages

Have fun!!

Jos & Rolf

Re: New Module Custom Global Settings

Posted: Sun Feb 19, 2012 2:59 pm
by Jo Morg
Looks great! I needed something like this a few ears back. :D
Another tool on the web-designer sleeve. Can't wait to try it.

Re: New Module Custom Global Settings

Posted: Fri Mar 16, 2012 6:25 pm
by Rolf
Change color on the frontend
Another option of the Custom Global Settings module, with a little imagination...

Option 1, Page or template
Create a Dropdown named "textcolor"
Values:
red|Red
blue|Blue
#000|Black
Because the stylesheets are cached, you need to clear the cache after each change. Check the checkbox "Clean cache"

Put in your page or template:

Code: Select all

{CustomGS}
<p style="color:{$CustomGS.textcolor}">Lorem Ipsum</p>
Option 2, Stylesheet
Add in the top of your stylesheet:

Code: Select all

[[CustomGS]]
To change for example the color of the p-text add:

Code: Select all

p {
color: [[$CustomGS.textcolor]];
}
Grtz. Rolf

Re: New Module Custom Global Settings

Posted: Sat Mar 17, 2012 6:37 pm
by Wishbone
Very nice!! I was about 30% into coding something similar (AdvancedGlobalContent), which presented a bunch of GCBs of different types (text, checkbox, etc) and had tab support, but stopped because I found another way

I currently put a bunch of content blocks in the template called 'settings', either using AdvancedContent or CGContentUtils, and have the user edit the fields in the 'settings' page that uses the 'settings' template... The values can easily be accessed through CGSimpleSmarty..

I'll check out your module.. Sounds fantastic!

Re: New Module Custom Global Settings

Posted: Sun Mar 18, 2012 7:17 pm
by Rolf
Thanks Wishbone
But the most credits go to Jos now! ;)

Re: New Module Custom Global Settings

Posted: Tue Mar 20, 2012 8:03 pm
by Jos
A new version of Custom Global Settings is just released.

Changelog:
- Minimum required CMSms version set to 1.10
- Add GetAdminSection setting (FR #7618)
- Added option to automatically clear cache after changing a setting
- Added fieldtype 'Button'
- Support Value|OptionName pairs and Smarty tags for pulldown fields and radiobuttons
- Bug fixed: Editing a field changes the fieldname
- Bug fixed: SendEvent on changing a checkbox setting

Also created a Wiki page in the CMSms documentation at http://wiki.cmsmadesimple.org/index.php ... alSettings

Re: New Module Custom Global Settings

Posted: Sun Jul 29, 2012 9:35 am
by requish
This module is AWESOME! Thanks to You very much!!!