Question

I´m working on a Joomla 2.5 site. The goal is to give the authors an easy way to output a list of categories when editing an article.

For this I wrote a small PHP Script which querys the needed content from the Db:

switch ($year) {
    case "2009":
        $id = "42";
        break;

 ...

 $db->setQuery('
  SELECT 
    #__categories.title
  FROM 
    #__categories 
  WHERE 
    #__categories.parent_id =' . $id .'
  ORDER BY #__categories.title ASC
    '
   ); 

$winners = $db->loadObjectList(); 

foreach($winners as $gewinner){
    echo $gewinner->title . "<br />";
    }

...

The Script takes a year as Input and uses it as $id. I´ve now looking for a way to easily integrate this into joomlas article editor. Great would be if the authors could insert something like

 ###2011### 

which then is converted to:

<?php
require_once '/homepages/16/d60007267/htdocs/content/testpage/templates/test/winners.php?j=2009';  
?>

when the article is rendered. I thought I could make an com_content override. But haven´t found a good point where to search and replace within the content.

thanks for help,

tbook

Was it helpful?

Solution

You have to look at content plugins and maybe editors-xtd plugins.

The content plugin will detect the special markup you put into the article and do whatever you need it to do with it. That is your whole script code should go into this plugin, not the require_once stuff. Usually plugin markup uses { and }, but you could use anything you want. You just create a proper REGEX for it to detect.

If this works you can also look at an editors-xtd plugin. This will then create a button below the editor which allows your authors to input the markup into the editor.

For examples, you can look at one of the simpler existing plugins.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top