0
Welcome Guest! Login
0 items Join Now

Plugin Question

  • Plugin Question

    Posted 17 years 1 month ago
    • Hey guys, I have tried to write my own plugin, but failed miserably :( The whole j1.5 framework is giving me headaches, with article->text pointers and regex str_replace ...

      That's why I'm posting here, where a lot of helpful coders run around :)

      Basically, I need a plugin that replaces {item}text{/item} with the following javascript, which uses the text as a variable.
      <script type="text/javascript"> if(tipcount){ tipcount = tipcount + 1; } else { var tipcount = 1 } document.write("<span id=\"tip-"+tipcount+"\"></span>"); sendRequest("{TEXT}", "tip-"+tipcount, "en"); </script><noscript>[{TEXT}]</noscript>

      and includes 2 .js files, overlib.js and tooltipnew.js

      Any advice other than: Write it yourself? =)
    • GollumX's Avatar
    • GollumX
    • Elite Rocketeer
    • Posts: 2817
    • Thanks: 0

    Re: Plugin Question

    Posted 17 years 1 month ago
  • Re: Plugin Question

    Posted 17 years 1 month ago
    • problem is, I don't want to include the .js files in every content item manually, I don't want to use the javascript to embed the tooltip every time, I want a plugin to do that for me, with the variable I give it.

      If I just wanted to include javascript once, that solution would work fine, but I'll have to use this for almost every content item there is on my site, multiple times per article!

      I have tried (unsuccessfully so far) to rewrite the rokzoom j1.5 plugin. The basic steps are the same, analyze the content between {rokzoom}{/rokzoom} and modify the output. I just need to use the javascript above to format my output, and have no idea how to accomplish that.
    • Last Edit: 17 years 1 month ago by Rudolf Ernenputsch.
  • Re: Plugin Question

    Posted 17 years 1 month ago
    • *bump*
      Could anyone do a plugin like this for me? Or at least for the whole of the World of Warcraft Community? Legendary Status would surely be yours then
  • Re: Plugin Question

    Posted 17 years 1 month ago
    • Got it work like this.
      <?php
      defined('_JEXEC') or die( "Direct Access Is Not Allowed" );
       
      jimport('joomla.event.plugin');
       
      class plgContentWoWItemstats extends JPlugin {
       
           function plgContentWoWItemstats( &$subject ) {
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent::__construct( $subject );
      &nbsp; &nbsp; }
       
      &nbsp; &nbsp; function onPrepareContent(&$article, &$params, $limitstart) {
                $regex = "#{wow}(.*?){/wow}#s";
                $article->text = preg_replace_callback($regex,array($this,"itemstats"), $article->text);
           &nbsp; &nbsp; return true;
      &nbsp; &nbsp; }
       
           function itemstats($matches) {
                $html&nbsp; = '';
                $html .= "<script type=\"text/javascript\">";
                $html .= "if(tipcount) { ";
                $html .= "tipcount = tipcount + 1}";
                $html .= "else {";
                $html .= "var tipcount = 1}";
                $html .= "document.write(\"<span id=\\\"tip-\"+tipcount+\"\\\"></span>\");";
                $html .= "sendRequest(\"". $matches[1] . "\", \"tip-\"+tipcount, \"en\");";
                $html .= "</script>";
                return $html;
           }
      }
    • Last Edit: 17 years 1 month ago by Rudolf Ernenputsch.
  • Re: Plugin Question

    Posted 17 years 1 month ago
    • alright, I've got it to work, if anyone want to know how, drop me a pm

Time to create page: 0.066 seconds