We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Creating first plug-in

Development and Programming

Vernierst's avatar
Vernierst
1 posts
15 years ago
Vernierst's avatar Vernierst

I’m adding some outside database queries to a EE template. It works great, but whenever I uncomment the pi_usage section of the $plugin_info array, it seems that the usage code is always run. When I view all the plugins, it just shows the usage information for my plugin, and when I view a template that uses the plugin, I just get the text for the plugin.

Here’s most of the code:

<?php
$plugin_info = array(
    'pi_name' => 'E21 Price Lookup',
    'pi_version' =>'0.75',
    'pi_author' =>'David Lim',
    'pi_description' => 'E21 Product Price Lookup (US Only)',
    'pi_usage' => E21_price::usage()
);

/**
 * E21_price Class
 *
 * @package        ExpressionEngine
 * @category        Plugin
 * @author        David Lim
 * @copyright        Copyright (c) 2010, David Lim
 */

class E21_price {

    var $return_data = '';

    function E21_price() {
        ...
    }

    function usage() {
        ob_start();
        ?>
The E21 Plugin provides product information from E21.
{exp:e21_price}part_code{/exp:e21_price}
        <?php
        $buffer = ob_get_contests();
        ob_end_clean();
        return buffer;
    }
}

Any suggestions?

       
Vernierst's avatar
Vernierst
1 posts
15 years ago
Vernierst's avatar Vernierst

Never mind, I figured it out. The exampled I pulled from, I don’t know why they used ob_start. All I had to do was return the text I wanted and not use any of the other code.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.