Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[RESOLVED] Plugin Theme : Sidebar option
#2
Here's an updated plugin file for you.

Should work as expected.

the problem was you were save the value of $_POST['sidebaractive'] whereas you should have been saving the value of your radio group 'option1'

added some code to the radio button to make sure the current value is also set.

Mike...

Code:
<?php
/*
Plugin Name: Cyclehome Theme Settings
Description: Settings for the default GetSimple 3.0 Theme: Cyclehome
Version: 1.0
Author: David Di Natale

based on the work of : Chris Cagle
Author URI: http://www.cagintranet.com/
*/

# get correct id for plugin
$thisfile=basename(__FILE__, ".php");
$cyclehome_file=GSDATAOTHERPATH .'cyclehomeSettings.xml';

# register plugin
register_plugin(
    $thisfile,                                                     # ID of plugin, should be filename minus php
    'cyclehome Theme Settings',                                     # Title of plugin
    '1.0',                                                             # Version of plugin
    'David Di Natale',                                            # Author of plugin
    '',             # Author URL
    'Settings for the default GetSimple 3.0 Theme: Cyclehome',     # Plugin Description
    'theme',                                                     # Page type of plugin
    'cyclehome_show'                                          # Function that displays content
);

# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile,'Cyclehome Theme Settings'));

# get XML data
if (file_exists($cyclehome_file)) {
    $x = getXML($cyclehome_file);

    $sidebaractive = $x->sidebaractive;
} else {

    $sidebaractive = "";
}


function cyclehome_show() {
    global $cyclehome_file, $facebook, $twitter, $linkedin, $sidebaractive, $success,$error;
    
    // submitted form
    if (isset($_POST['submit'])) {
        
        $sidebaractive = $_POST['option1'];
    
        # if there are no errors, save data
        if (!$error) {
            $xml = @new SimpleXMLElement('<item></item>');
            
            $xml->addChild('sidebaractive', $sidebaractive);
            
            if (! $xml->asXML($cyclehome_file)) {
                $error = i18n_r('CHMOD_ERROR');
            } else {
                $x = getXML($cyclehome_file);
                $sidebaractive = $x->sidebaractive;
                $success = i18n_r('SETTINGS_UPDATED');
            }
        }
    }
    
    ?>
    <h3>cyclehome Theme Settings</h3>
    
    <?php
    if($success) {
        echo '<p style="color:#669933;"><b>'. $success .'</b></p>';
    }
    if($error) {
        echo '<p style="color:#cc0000;"><b>'. $error .'</b></p>';
    }
    ?>
    
    <form method="post" action="<?php    echo $_SERVER ['REQUEST_URI']?>">
        
        <p><label for="sidebaractive" >Activate Sidebar ?</label><input type="radio" name="option1" value="YES" <?php if($sidebaractive=="YES") echo "checked"; ?>> YES <input type="radio" name="option1" value="NO" <?php if($sidebaractive=="NO") echo "checked"; ?>> NO <br>
        
        <p><input type="submit" id="submit" class="submit" value="<?php i18n('BTN_SAVESETTINGS'); ?>" name="submit" /></p>
    </form>
    
    <?php
}
My Github Repos: Github
Website: DigiMute
Reply


Messages In This Thread
[RESOLVED] Plugin Theme : Sidebar option - by n00dles101 - 2012-03-07, 22:24:08



Users browsing this thread: 1 Guest(s)