The vB Geek

Go Back   The vB Geek > vB Geek Modifications > Tutorials

Tutorials Tutorials and articles on using vB Geek stuff.

Advertisement
  Learn how to remove ads

Comment
 
Tutorial Tools Display Modes
GARS: Module making 102
GARS: Module making 102
Published by The Geek
02-22-2006
Default Introduction

In the 101 tutorial, I showed a very brief, easy way to add custom field capturing to GARS. In this version, I build off of the example given and create a slightly more sophisticated version to show off a couple more stages.

In this version of the Movie rating pull down box, I add the ability for the admin to select which ratings to show in the pull down box via the Settings stage and the persist settings stage. I am assuming you have already read the 101 tutorial!

Please note that this is not exactly how I would approach this, its just meant to try and be a guide that should be semi easy to follow .

Make sure you clean the input!

Here is the 102 completed code:
PHP Code:
<?php
 
if ($stage == "settings")
    {
     
print_description_row("This module will allow users to select a rating for the movie");
        if (
$settings['my_rating_settings'])
        {
         foreach(
$settings['my_rating_settings'] as $key => $value)
            {
             if (!
$keys)
                {
                 
$keys ="$key";
                    
$texts "$value";
                }
                else
                {
                 
$keys .=",$key";
                    
$texts .= ",$value";
                }
            }
        }
        
print_input_row("Ratings:<dfn>Enter each rating letter seperated by a comma (i.e. G,PG,R)</dfn>""my_rating_keys[$itemid]"$keys);
        
print_input_row("Text:<dfn>Enter each rating description seperated by a comma (i.e. G - General,PG - Parental Guidance</dfn>""my_rating_text[$itemid]"$texts);
    }
    elseif (
$stage == "persistsettings")
    {
        global 
$vbulletin;
        
$vbulletin->input->clean_array_gpc('p',array(
         
'my_rating_keys'  =>  TYPE_ARRAY_ARRAY_STR,
            
'my_rating_text' => TYPE_ARRAY_ARRAY_STR
        
));
        
$keys $vbulletin->GPC['my_rating_keys'][$itemid];
  
$text $vbulletin->GPC['my_rating_text'][$itemid];
        
$keyarray explode(",",$keys);
        
$textarray explode(","$text);
        
$results = array();
        if (
is_array($keyarray))
        {
         foreach(
$keyarray as $itemkey => $itemvalue)
            {
             
$results[$itemvalue] = $textarray[$itemkey];
            }
        }
        
$settings['my_rating_settings'] = $results;
    }
    elseif (
$stage == "edit")
    {
        
$items $settings['my_rating_settings'];
        if (
is_array($items))
        {
         
$output .= "Rating: <SELECT name=\"custom1[my_rating]\">";
            foreach(
$items as $arraykey => $arrayvalue)
            {
                if (
$values['my_rating'] == $arraykey)
                {
                 
$selected "selected=\"selected\"";
                }
                else
                {
                 
$selected "";
                }
                
$output .= "<OPTION value=\"$arraykey\" $selected >$arrayvalue</OPTION>";
            }
            
$output .="</SELECT>";
        }
    }
    elseif(
$stage == "persist")
    {
        
$my_rating $this->vb->GPC['custom1']['my_rating'];
        
$values['my_rating'] = $my_rating;
    }
    elseif(
$stage == "display")
    {
        
$title "Rating";
        
$items $settings['my_rating_settings'];
        
$bits "<tr><td class=\"alt1\" align=\"center\">" $items[$values['my_rating']] . "</td></tr>";
  eval(
'$output.="' fetch_template('GARS_mod_container') . '";');
    }
?>
Tutorial for
GARS

Contents

Tutorial Tools
Show Printable Version  Email this Page 

<< <    Next Page: Settings stage (Page 1 of 7)    >  >>
Comment

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 11:01 AM
making a gab block for gars benj Geek Advertising Banner System 12 08-21-2006 09: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 10: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 05:57 PM
yes I know....another one making suggestions ;) effectica GeekMart 1 02-08-2006 07:05 PM


All times are GMT. The time now is 10:50 PM.


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

Tutorial powered by GARS 2.1.9 ©2005-2006