Calling a {Plugin} in PHP code

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
paulmason411
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Dec 19, 2006 6:56 am
Contact:

Calling a {Plugin} in PHP code

Post by paulmason411 » Wed May 13, 2009 5:26 am

Hi Guys,

I am using the 'accordion menu apple style' plugin, and can access it by typing the following in an articels text box:

Code: Select all

{Accordion_Menu_Apple_style}
<a href="http://www.site1.com">Clothing</a>
- <a href="http://www.site1.com">Shirts</a>
- <a href="http://www.site1.com">Shorts</a>
- <a href="http://www.site1.com">Pants</a>
- <a href="http://www.site1.com">Skirts</a>
- <a href="http://www.site1.com">Dresses</a>
<a href="http://www.site1.com">Accessories</a>
- <a href="http://www.site1.com">Shirts</a>
- <a href="http://www.site1.com">Shorts</a>
- <a href="http://www.site1.com">Pants</a>
- <a href="http://www.site1.com">Skirts</a>
- <a href="http://www.site1.com">Dresses</a>
<a href="http://www.site1.com">Jewellery</a>
{/Accordion_Menu_Apple_style}
I want to try and use this style for the virtuemart category menu. I am new to the Joomla 1.5 Framework and am not sure how to call a plugin within php. If I try adding that {Accordion_Menu_Apple_style} into the php i get a syntax error.

Has anyone come across this before, or have a similar solution?

Cheers,
Paul
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
» http://paulmason.name - Web Development Blog «
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

paulmason411
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Dec 19, 2006 6:56 am
Contact:

Re: Calling a {Plugin} in PHP code

Post by paulmason411 » Thu May 14, 2009 7:16 am

Did I post this in the wrong forum category, or do I need to explain it better? Please let me know. Thanks.
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
» http://paulmason.name - Web Development Blog «
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: Calling a {Plugin} in PHP code

Post by dam-man » Thu May 14, 2009 7:55 am

I don't know it thjis is working.
Is this just a PHP file or are you creating a component?
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

paulmason411
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Dec 19, 2006 6:56 am
Contact:

Re: Calling a {Plugin} in PHP code

Post by paulmason411 » Mon May 18, 2009 3:52 am

The php file i want to edit is a component. It's the virtuemart component. Basically I want to get the same effect of using the plugin braces {} in a textbox but in a php file.

So if {plugin_test} hello world {/plugin_test} rendered out to <table id='plugin_test'> hello world </table> then how do i get those same results in a joomla php file. I'm guesing it would be something like plugin['plugin_test'].input('hello world'); I'm just not familiar with the syntax of the joomla 1.5 framework.

Any help would be great. Thanks.
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
» http://paulmason.name - Web Development Blog «
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Re: Calling a {Plugin} in PHP code

Post by meloman » Mon May 18, 2009 11:21 am

Your extension need to output the same code the plugin understand

Code: Select all

echo '{Accordion_Menu_Apple_style}';
 .... 
echo '{/Accordion_Menu_Apple_style}';
...then the plugin should work.
http://aldra.ca :: My latest little projects

paulmason411
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Dec 19, 2006 6:56 am
Contact:

Re: Calling a {Plugin} in PHP code

Post by paulmason411 » Wed May 20, 2009 1:04 pm

meloman wrote:Your extension need to output the same code the plugin understand

Code: Select all

echo '{Accordion_Menu_Apple_style}';
 .... 
echo '{/Accordion_Menu_Apple_style}';
...then the plugin should work.
When I echo '{Accordion_Menu_Apple_style}'; it just prints {Accordion_Menu_Apple_style} straight to the html. Do i need to import a file to render a {plugin} in the echo statement?

Can anyone hear use the Joomla API or point me in the right direction. I've been to this page: http://api.joomla.org/li_Joomla-Framework.html and I can't see an efficient way to learn from it. I have to read through class by class and the descriptions don't explain things very well.
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
» http://paulmason.name - Web Development Blog «
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

User avatar
meloman
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 106
Joined: Sun Oct 22, 2006 1:29 am
Location: Montréal
Contact:

Re: Calling a {Plugin} in PHP code

Post by meloman » Wed May 20, 2009 11:10 pm

Hmmm... I thought the plugin would catch the {Accordion_Menu_Apple_style} and replace it with the appropriate code. Maybe the plugin don't process the code from the modules. I'm not an expert in plugin, maybe someone else can help you with that problem! :(
http://aldra.ca :: My latest little projects

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11614
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Calling a {Plugin} in PHP code

Post by ooffick » Thu May 21, 2009 12:09 pm

Hi, You will need to trigger the event to call the plugin as well.

In your case, I believe this would be something like this:

Code: Select all

global $mainframe;

$content = '{Accordion_Menu_Apple_style}';
$content .= '<a href="http://www.site1.com">Shirts</a>';
/*... */
$content .= '{/Accordion_Menu_Apple_style}';

$article = new stdClass();
$article->text = $content;
$dispatcher	=& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$limitstart = 0;
$params = array();
$results  = $dispatcher->trigger('onPrepareContent', array (& $article, & $params, $limitstart));
echo $article->text;
Olaf Offick - Global Moderator
learnskills.org

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Calling a {Plugin} in PHP code

Post by ianmac » Thu May 21, 2009 3:29 pm

ooffick wrote:Hi, You will need to trigger the event to call the plugin as well.

In your case, I believe this would be something like this:

Code: Select all

global $mainframe;

$content = '{Accordion_Menu_Apple_style}';
$content .= '<a href="http://www.site1.com">Shirts</a>';
/*... */
$content .= '{/Accordion_Menu_Apple_style}';

$article = new stdClass();
$article->text = $content;
$dispatcher	=& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$limitstart = 0;
$params = array();
$results  = $dispatcher->trigger('onPrepareContent', array (& $article, & $params, $limitstart));
echo $article->text;

Hmm... that's one way to do it...

I'd probably do something more like:

Code: Select all

$content = '{Accordion_Menu_Apple_style}';
$content .= '<a href="http://www.site1.com">Shirts</a>';
/*... */
$content .= '{/Accordion_Menu_Apple_style}';
$content = JHTML::_('content.prepare', $content);
Ian

juicyfruit
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Mon Jan 16, 2006 10:43 am
Location: Australia
Contact:

Re: Calling a {Plugin} in PHP code

Post by juicyfruit » Wed May 27, 2009 3:14 pm

Hi,

hope someone can help.

I'm using:
- joomla 1.5.
- jumi 2.1
- plugin_googlemap_J15.2.12i

I'm using jumi. I assume it's similiar to calling the plugin via a php file.

I am trying to call the plugin {mosmap} from

tech.reumer.net

ie. google maps


I have got

Code: Select all

$mosmapCall = '{mosmap address='1 pitt st, 2000, sydney, South Australia,Australia'} ;

$mosmapCall = JHTML::_('plugin_googlemap2.prepare', $mosmapCall);
Am I missing something?

All that results is that the text gets displayed.

thanks in advance.

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Calling a {Plugin} in PHP code

Post by ianmac » Wed May 27, 2009 3:42 pm

juicyfruit wrote:Hi,

hope someone can help.

I'm using:
- joomla 1.5.
- jumi 2.1
- plugin_googlemap_J15.2.12i

I'm using jumi. I assume it's similiar to calling the plugin via a php file.

I am trying to call the plugin {mosmap} from

tech.reumer.net

ie. google maps


I have got

Code: Select all

$mosmapCall = '{mosmap address='1 pitt st, 2000, sydney, South Australia,Australia'} ;

$mosmapCall = JHTML::_('plugin_googlemap2.prepare', $mosmapCall);
Am I missing something?

All that results is that the text gets displayed.

thanks in advance.
Yes... there is no such class as JHTMLPlugin_googlemap2
it should be:
JHTML::_('content.prepare', $mosmapCall);

Ian

juicyfruit
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Mon Jan 16, 2006 10:43 am
Location: Australia
Contact:

Re: Calling a {Plugin} in PHP code

Post by juicyfruit » Wed May 27, 2009 11:05 pm

Thankyou Ian for responding.

It really helped. ;-)

The code in jumi that was working is as follows:

Code: Select all

<?php 

echo "hello world!";

$mosmapCall = '{mosmap}' ;

$mosmapCall = JHTML::_('content.prepare', $mosmapCall);

echo $mosmapCall;

?>

paulmason411
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Dec 19, 2006 6:56 am
Contact:

Re: Calling a {Plugin} in PHP code

Post by paulmason411 » Fri May 29, 2009 3:41 am

Thanks Olaf & Ian,

Both solutions worked!

Just one more quick question:

If I were to find these solutions using the documentation provided by Joomla where would I look. Is there a problem solving process you can explain to this solution. The more detail the better (such as using api's, debugging etc.).

Thanks again,
Paul
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
» http://paulmason.name - Web Development Blog «
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••


Locked

Return to “Joomla! 1.5 Coding”