Forgive me if this is a noob question.
I built a simple plugin to scratch an itch, but can’t get it working.
The plugin shows up as installed in Cp > Addons > Plugins
But when I try to use the tags
{exp:myplugin}{/exp:myplugin}
I get an error that says ‘the module is not installed’
any idea why I’m getting this? here’s the precise error
Error
The following tag cannot be processed:
{exp:get_iframe_src}
Please check that the ‘get_iframe_src’ module is installed and that ‘get_iframe_src’ is an available method of the moduleSeems to have trouble finding the file, class, or method.
You use two examples above - once myplugin and once get_iframe_src.
I won’t make any assumptions, so let’s start with the basics:
What is the plugin called and where did you place it? What is the file name, and what is the class name?
ya, I should be more precise sorry
the plugin is caled Getiframesrc
it’s a quick and dirty way for me to pull the src attribute out of some video embed code
at first I was trying to return the value from the constructor function, but that didn’t seem to work
I added another method and called that and it does seem to return a value
don’t laugh when you see it though
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Get Iframe SRC',
'pi_version' => '1.0',
'pi_author' => 'Mike Moreau',
'pi_author_url' => 'http://harvestmedia.com',
'pi_description' => 'Looks for the src attribute of an iframe and returns it.'
);
class Getiframesrc
{
function __construct()
{
$this->EE =& get_instance();
}
function do_it()
{
$input = $this->EE->TMPL->tagdata;
$sx = simplexml_load_string('<xml>'.$input.'</xml>');
if($sx)
{
if($sx->iframe['src'])
{
return $sx->iframe['src'];
}
else
{
return 'could not find src attribute';
}
}
else
{
return 'could not parse url from embed code';
}
}
}
/* End of file pi.get_iframe_src.php */
/* Location: ./system/expressionengine/third_party/getiframesrc/pi.getiframesrc.php */To return something from the constructor you must assign the value to $this->return_data; This is because a constructor returns an instance of the class and thereby cannot return another value to be inserted into the template.
The class name of your plugin is Getiframesrc so you need to call the plugin in the template with the same name - no unerscores. Ex:
{exp:getiframesrc}...{/exp:getiframesrc}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.