Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Innovation Plugin
#1
Needed to extend Innovation Theme plugin with some Dutch Social Networks and remove some others. As a lazy developer as I am I've inserted an array into the plugin and changed the code for dynamical reading.

Code:
<?php
/*
Plugin Name: Innovation Theme Settings
Description: Settings for the default GetSimple 3.0 Theme: Innovation
Version: 1.1
Author: Chris Cagle
Author URI: http://www.cagintranet.com/
*/

# get correct id for plugin
$thisfile_innov=basename(__FILE__, ".php");
$innovation_file=GSDATAOTHERPATH .'InnovationSettings.xml';

# add in this plugin's language file
i18n_merge($thisfile_innov,'en_US');

# register plugin
register_plugin(
    $thisfile_innov,                                                     # ID of plugin, should be filename minus php
    i18n_r($thisfile_innov.'/INNOVATION_TITLE'),                 # Title of plugin
    '1.1',                                                             # Version of plugin
    'Chris Cagle',                                            # Author of plugin
    'http://www.cagintranet.com/',             # Author URL
    i18n_r($thisfile_innov.'/INNOVATION_DESC'),                     # Plugin Description
    'theme',                                                         # Page type of plugin
    'innovation_show'                                      # Function that displays content
);

# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_innov, i18n_r($thisfile_innov.'/INNOVATION_TITLE')));

# change /add / remove your Social Networks here ...
$innovation = Array('facebook','twitter','linkedin','hyves','plaxo');

# get XML data
if (file_exists($innovation_file)) {
    $x = getXML($innovation_file);
    foreach($innovation as $key => $value) {
        $social[$value] = $x->$value;
    }
} else {
    foreach($innovation as $key => $value) {
        $social[$value] = '';
    }
}


function innovation_show() {
    global $innovation_file, $thisfile_innov, $innovation, $social;
    
    // submitted form
    if (isset($_POST['submit'])) {
        foreach($innovation as $key => $value) {
            $social[$value] = null;
        }
        
        # check to see if the URLs provided are valid
        foreach($innovation as $key => $value) {
            if ($_POST[$value] != '') {
                if (validate_url($_POST[$value])) {
                    $social[$value] = $_POST[$value];
                } else {
                    $error .= i18n_r($thisfile_innov.'/'.strtoupper($value).'_ERROR').' ';
                }
            }
        }
        
        # if there are no errors, dave data
        if (!$error) {
            $xml = @new SimpleXMLElement('<item></item>');
            foreach($innovation as $key => $value) {
                $xml->addChild($value, $social[$value]);
            }
            if (! $xml->asXML($innovation_file)) {
                $error = i18n_r('CHMOD_ERROR');
            } else {
                $x = getXML($innovation_file);
                foreach($innovation as $key => $value) {
                    $social[$value] = $x->$value;
                }
                $success = i18n_r('SETTINGS_UPDATED');
            }
        }
    }
    
    ?>
    <h3><?php i18n($thisfile_innov.'/INNOVATION_TITLE'); ?></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']?>">
        <?php foreach($innovation as $key => $value) { ?>
            <p><label for="inn_<?php echo $value ?>" ><?php i18n($thisfile_innov.'/'.strtoupper($value).'_URL'); ?></label><input id="inn_<?php echo $value ?>" name="<?php echo $value ?>" class="text" value="<?php echo $social[$value]; ?>" /></p>
        <?php } ?>
        <p><input type="submit" id="submit" class="submit" value="<?php i18n('BTN_SAVESETTINGS'); ?>" name="submit" /></p>
    </form>
    
    <?php
}
Reply
#2
this is great -
i was able to adapt this into a new plugin for a custom theme, and it perfectly creates the relevant xml file to store the settings...

however for some reason i can't seem to get the template function to read the xml values.

I have this code in my functions.php:

Code:
function Delphic_Settings() {
    $file = GSDATAOTHERPATH . 'DelphicSettings.xml';
    if (file_exists($file)) {
        $p = getXML($file);
        if ($p->facebook != '' ) define('FACEBOOK', $p->facebook);
        if ($p->twitter != '' ) define('TWITTER', $p->twitter);
        if ($p->linkedin != '' ) define('LINKEDIN', $p->linkedin);
        if ($p->flickr != '' ) define('FLICKR', $p->flickr);
        if ($p->dribbble != '' ) define('DRIBBBLE', $p->dribbble);
        return true;
    } else {
        return false;
    }
}

and i have this in my template footer:

Code:
<?php if (defined('TWITTER')) { ?>
          <li><a href="<?php echo TWITTER; ?>"><img src="<?php get_theme_url(); ?>/style/images/icon-twitter.png" alt="" /></a></li>
          <?php } ?>

i can't seem to figure out why this doesn't work...it should be as simple as the functions.php file getting the values from the xml file and then the template using those values...

I also tried using the regular Innovation Plugin on a different template, and copied the functions.php to the other theme folder and copied the code exactly from the Innovation theme, but it doesn't work there either..

would be great to solve this because it could be the beginnings of a generic theme settings plugin that could be used for other themes...

-marc
Reply
#3
Please can you tell me how can I add Google+ and YouTube in Innovation theme settings?

What are the steps?
I believe that is a code like:
if ($p->flickr != '' ) define('FLICKR', $p->flickr);
But what other changes?
Like some other codes and of course an icon to display.

Thanks
Reply
#4
If you know enough php it shouldn't be difficult. (Some code should be added at several places in plugins/InnovationPlugin.php and theme/.../functions.php)

But if you don't, the easy way is simply editing sidebar.inc.php (in Theme -> Edit) and using html to add any links you need in the Connect section.
Reply
#5
ooops
Reply
#6
That's great, Oleg. Thanks for sharing.

It would be nice that the GS team updated the Innovation theme with your additions, or else you upload a full modified version to Extend.
Reply
#7
for some reason me requested to register
http://get-simple.info/extend/
Reply
#8
[offtopic]
Try logging out of the forum, clear cookies, log in again...
Reply
#9
http://www.youtube.com/watch?v=cMnx18lxA-8
Reply
#10
Thank you Oleg. This should be the official theme.

Oleg I tested but somehow the icons get on that tab "CONNECT".
I attached the screenshot.
Is it something extra to do it?

Thank you for your patience.


Attached Files Thumbnail(s)
   
Reply
#11
apparently this theme is only for 3 icons.
Try to place the code in the sidebar below.
Reply
#12
(2012-11-08, 16:19:59)Oleg06 Wrote: apparently this theme is only for 3 icons.
Try to place the code in the sidebar below.

Is it possible to place it in the same position but with </ br> to send the icons on the next row below?
Reply
#13
You can place the code in the file sidebar.inc.php as you like
Reply
#14
You guys know you can just goto add this and make your own and throw it in there. It doesn't have to be in the theme.
https://www.addthis.com/get/sharing#.UJ_GwId2zoo
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#15
I have added this to core
innovation theme social

actually I rewrote it myself, I didn't see this thread. Oh well, i basically did the same exact thing as rne.

https://github.com/GetSimpleCMS/GetSimpleCMS/issues/520
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#16
somehow button plugin settings suddenly stopped in other topics
Reply
#17
What does that mean?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#18
I always used an old version of this plugin with different themes, and now I can not
Reply
#19
3.2.2 hides the plugin if the innovation theme is not the current theme

https://github.com/GetSimpleCMS/GetSimpl...ed0676cf37
I guess you can just revert this change.

assuming this is what you mean ?
You should clone the plugin and change the code to match your theme name
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#20
I just modified it with a toggle

https://github.com/GetSimpleCMS/GetSimpl...a37801a8ac
will be in 3.3.2
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#21
You can also still get to it manually
/admin/load.php?id=InnovationPlugin
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#22
thanks for the tip, it works Smile
Reply




Users browsing this thread: 2 Guest(s)