Welcome, Guest
Username: Password: Remember me

TOPIC: Simple joomla hello world plugin question.

Simple joomla hello world plugin question. 11 years 3 months ago #5

  • denislux
  • denislux's Avatar
Hi, could you help me to modify the following code to display the hello world message within the content articcle
in tags {embed}Hello World{/embed}


PHP
<?php

// no direct access
defined('_JEXEC') or die;

class plgContentHelloworld extends JPlugin
{
public function onContentAfterTitle($context, &$article, &$params, $limitstart)
{
return "<p>Hello World!</p>";
}
}

?>

XML
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="content">
<name>plg_content_helloworld</name>
<author>xxx</author>
<creationDate>September 11th, 2013</creationDate>
<copyright>Freelancer</copyright>
<license>GNU General Public License</license>
<authorEmail>This email address is being protected from spambots. You need JavaScript enabled to view it.</authorEmail>
<authorUrl>www.joomla.com</authorUrl>
<version>1.0</version>
<description>Simple Hello World Plugin that prints "Hello World" at the beginning of every article.</description>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
</files>
</extension>
The administrator has disabled public write access.

Simple joomla hello world plugin question. 11 years 3 months ago #6

  • denislux
  • denislux's Avatar
The next step is to parse and pass on some custom parameter values within the {embed}.....{/embed} tags.
For example I would like the joomla user to be able to put on the backend content page:
{embed}action=buy,product1=laptop,brand1=Dell,price1=400{/embed}

now, the output would be a plain text within article:
(Button)|Buy| Dell, 400 Eur

Now, i would like to be able to have multiple products, 1-3 within dropdown with a single buy button. So the {} would be something like:
{embed}action=buy,product1=laptop,brand1=Dell,price=400,product2=monitor,brand2=Sony,price2=350,product3=keyboard,brand3=Logitec,price3=15{/embed}

output in html would be something like...
<select name="product">
<option value=Laptop Dell">Laptop Dell €400 EUR</option>
<option value="Monitor Sony">Monitor Sony €350 EUR</option>
<option value="Keyboard Logitec">Keyboard Logitec 15 EUR</option>
</select>
<input type="submit" value="buy">


Please let me know how i could achieve this.
The administrator has disabled public write access.

Simple joomla hello world plugin question. 11 years 3 months ago #7

  • mihir
  • mihir's Avatar
your user will enter in backend - "{embed}action=buy,product1=laptop,brand1=Dell,price1=400{/embed}" and it will be displayed in front end like "Buy button Dell, 400 Eur".
I did not find if joomla allowed this kind of parameter based replacement with reference this article showing simple replace -
programminghelp24.com/articles/joomla/ho...des-by-joomla-plugin

So why not you go make a module for backend instead a plugin.That module will have some product entry form and user will enter appropriate data and you display those data from database table as output by organizing at front end.There are many related ways.

If you still wanna go B) with what you want.what you can do is in your plugin take the text content inside <embed> and </embed>, then split the content by comma to get an array like -
[0] action=buy
[1] product1=laptop
........................
then you display the values of array by formatting by replacing whole <embed>action=buy,....</embed> with your formatted html or scripts if needed.
you need to do some hard programming :cheer:
The administrator has disabled public write access.
Time to create page: 0.111 seconds
Powered by Kunena Forum

Latest discussions

  • No posts to display.