1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

working on a plugin, can't get it to install

Discussion in 'General Troubleshooting' started by blinger187, Jun 27, 2013.

  1. blinger187

    blinger187 New Member

    It doesn't even show up in the available plugins. This is my first plugin. I am editing an existing plugin to my needs. This new plugin will be an ad/banner rotation script.

    What is causing this to not even show up in the available plugins to install?



     * name: Ad Rotate
     * description: Rotate Banner Advertisements
     * version: 0.1
     * folder: ad_rotate
     * class: ad_rotate
     * hooks: install_plugin, header_include, admin_sidebar_plugin_settings, admin_plugin_settings, show_ads,
     * author: HIPHOPVIP
     * PHP version 5
     * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 
     * modify it under the terms of the GNU General Public License as 
     * published by the Free Software Foundation, either version 3 of 
     * the License, or (at your option) any later version. 
     * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
     * You should have received a copy of the GNU General Public License along 
     * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
     * @category  Content Management System
     * @package   HotaruCMS
     * @author    Nick Ramsay <admin@hotarucms.org>
     * @copyright Copyright (c) 2009, Hotaru CMS
     * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
     * @link      http://www.hotarucms.org/
    class ad_rotate
        public function install_plugin($h)
            // Plugin settings
            $ad_rotate_settings = $h->getSerializedSettings();
            if (!isset($ad_rotate_settings['pub_id'])) { $ad_rotate_settings['pub_id'] = "xxxxxxxxxx"; }
            $h->updateSetting('ad_rotate_settings', serialize($ad_rotate_settings));
    	public function header_include($h)
    		// include a file that match the name of the plugin folder:
    		// $h->includeJs();
        public function show_ads($h)
    		$ad_rotate_settings = $h->getSerializedSettings();
    		$ad_rotate_pub_id = $ad_rotate_settings['pub_id'];
    		$ad_rotate_ad_id = $ad_rotate_settings['ad_id'];
    		echo "<div class=\"box-list ad-show-in-list\">";
    		echo "<a href=\"".$ad_rotate_pub_id."\"><img src=\"".$ad_rotate_ad_id."\"></a>;\n";
    		echo "</div>";

    class AdRotateSettings
         * Admin settings for the AD Rotater plugin
        public function settings($h)
    		// show header
    		echo "<h2>Ad Rotater Settings</h2>\n";
    		if ($h->cage->post->getAlpha('submitted') == 'true') { 
    		// Get settings from database if they exist...
            $ad_rotate_settings = $h->getSerializedSettings();
    		if ( empty($ad_rotate_settings['pub_id']) ) { $ad_rotate_settings['pub_id'] = ''; }
    		if ( empty($ad_rotate_settings['ad_id']) ) { $ad_rotate_settings['ad_id'] = ''; }
    		// start form
            echo "<form name='ad_rotate_settings_form' action='" . BASEURL . "admin_index.php?page=plugin_settings&amp;plugin=ad_rotate' method='post'>\n";
            // instructions		
    		echo '
    		<table border="0" cellspacing="0">
    				<td colspan="2">
    					<h4>Publisher ID</h4>
    					<input type="text" name="ad_rotate_pub_id" id="ad_rotate_pub_id" value="' . $ad_rotate_settings['pub_id'] . '" />
    				<td colspan="2">
    					<h4>Ad Id</h4>
    					<input type="text" name="ad_rotate_ad_id" id="ad_rotate_ad_id" value="' . $ad_rotate_settings['ad_id'] . '" />
            // end form
            echo "<br />";
            echo "<input type='hidden' name='submitted' value='true' />\n";
            echo "<input type='submit' value='SAVE' />\n";
            echo "<input type='hidden' name='csrf' value='" . $h->csrfToken . "' />\n";
            echo "</form>\n";
         * Save Add This settings
        public function saveSettings($h)
    		$ad_rotate_settings = $h->getSerializedSettings(); 
    		$ad_rotate_pub_id = $h->cage->post->testAlnumLines('ad_rotate_pub_id');
    		$ad_rotate_ad_id = $h->cage->post->testAlnumLines('ad_rotate_ad_id');
    		// Save settings
    		$ad_rotate_settings['pub_id'] = $ad_rotate_pub_id;
    		$ad_rotate_settings['ad_id'] = $ad_rotate_ad_id;
    		$h->updateSetting('ad_rotate_settings', serialize($ad_rotate_settings));
    		$h->message = $h->lang["pubid_settings_saved"];
    		$h->messageType = "green";
            // show message
            return true;

    the script is not complete, i just want to ensure i can install it before i add in the rotating part
  2. valMETNG

    valMETNG Administrator Staff Member Admin

    Well, I noticed a few things that might help. It appears that hotaru expects the heading not be double-spaced. Also, there was a comma after your last hook. Your settings file also doesn't have an ending ?>. I've modified those errors and attached - see if this works (it did for me).

    View attachment ad_rotate.zip
    shibuya246 and Nick like this.
  3. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    Also, there is an old site page which needs updating but might help you if you are making a plugin for the first time and just want to get something installed


    You can fill in basic details at the top and choose some plugin hooks
    There is a main page and settings page

    I may try and update this later, but if you want it might help a little
  4. valMETNG

    valMETNG Administrator Staff Member Admin

    HA! Now the only thing that would make this cooler is if you could enter the functionality you want the plugin to do in another field and it would generate the code for you. The next step in Hotaru's progression... artificial intelligence :)
    shibuya246 likes this.
  5. blinger187

    blinger187 New Member

    this is very nice, thank you!

    I'm new to plugins and php in general so i've been splicing and hacking things together.

Share This Page