The vB Geek

Go Back   The vB Geek > vB Geek Modifications > Tutorials

Tutorials Tutorials and articles on using vB Geek stuff.

This is an HTML example. Isn't it just wonderful?!?!
  Learn how to remove ads

Tutorial Tools Display Modes
GARS: Module making 102
GARS: Module making 102
Published by The Geek
Default Persist Settings

The persistsettings stage allows you to process and save the settings.

I start by sanitizing any values (always best practice). I start by decalring $vbulletin as global so I can access it. Then I call vbulletins sanitizing proceedure. Each type is a string, and since its a multidimensional array, its declared as TYPE_ARRAY_ARRAY_STR. If it was a number, it would be TYPE_ARRAY_ARRAY_INT. The reason its a multi dimensional array is because a user may have 1 or 1,000 of this exact same module in the same set, each with its own unique settings. This enables you to keep the settings unique!Notice how I do this:
PHP Code:
        global $vbulletin;
'my_rating_keys'  =>  TYPE_ARRAY_ARRAY_STR,
'my_rating_text' => TYPE_ARRAY_ARRAY_STR
Then I put the values in a local variables:
PHP Code:
        $keys $vbulletin->GPC['my_rating_keys'][$itemid];
$text $vbulletin->GPC['my_rating_text'][$itemid]; 
Notice how I access it with the $itemid variable? This ensures I am getting the values ONLY FOR THIS MODULE!

Here is where I do some silly processing of the values. For simplicity, I am turning the values into an associative array so that the Key becomes the rating (i.e. G or PG) and the text becomes the value. This simplifies the display portion:
PHP Code:
        $keyarray explode(",",$keys);
$textarray explode(","$text);
$results = array();
        if (
$keyarray as $itemkey => $itemvalue)
$results[$itemvalue] = $textarray[$itemkey];
NOTE: This assumes that they have passed values through correctly (i.e. the same amount of keys as text and each key unique). They may not! However we are assuming they have

Finally, I set the results to the $settings array:
PHP Code:
$settings['my_rating_settings'] = $results
Phew. The rest is downhill from here

Tutorial for


Tutorial Tools
Show Printable Version  Email this Page 

<<  <    Next Page: Edit stage (Page 3 of 7)    >  >>

Tutorial Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Tutorial Tutorial Starter Category Comments Last Post
GARS: Module making 101 The Geek Tutorials 1 08-27-2008 10:01 AM
making a gab block for gars benj Geek Advertising Banner System 12 08-21-2006 08:42 AM
Does anyone have a GARS module that allows an image to be loaded in the module... FRAiD Geek Article and Review System 6 02-11-2006 09:57 AM
If I am using GARS for game reviews, and start making reviews and add new modules... FRAiD Geek Article and Review System 1 02-10-2006 04:57 PM
yes I know....another one making suggestions ;) effectica GeekMart 1 02-08-2006 06:05 PM

All times are GMT. The time now is 04:53 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

Tutorial powered by GARS 2.1.9 ©2005-2006