HAllo alle,
ich hab da einen Knoten im Hirn bei einem search plugin das mit eine id nicht ausliest.

Der Link der momentan zurückgegeben wird hat einen Fehler und zwar wird die ID des Artikels nicht mit eingetragen: z.B.
...../index.php?option=com_gamesbox&view=document&layout =preview&id=(HIER SOLLTE DIE ID HIN)test&lang=de

Leider hat der gute Frederik der das erstellt hat wohl keine Lust mehr die Jungs von Jooforge zu unterstützen und die haben anscheinend keine Ahnung von dem Plugin also versuche ich gerade das ganze Lauffähig zu bekommen....

Ich habe in die Query a.id AS id, eingefügt aber beim zusammenstellen des Rückgabewertes scheint er das zu ignorieren. Ich komme einfach nicht auf den Fehler denn eigentlich müsste er laut Code das ganze zusammenfügen.

Hat vielleicht jemand eine Idee?

Danke und grüße


Code:
<?php


//First start with information about the Plugin and yourself. For example:
/**
* @version             gamesbox.php 1.0 06/01/2011 Frederik Madsen Gamerocket.dk
* @copyright           Copyright
* @license             GNU/GPL
*/

//To prevent accessing the document directly, enter this code:
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

//Define the registerEvent and the language file. Replace 'nameofplugin' with the name of your plugin.
$mainframe->registerEvent( 'onSearch', 'plgSearchGamesboxsearch' );
$mainframe->registerEvent( 'onSearchAreas', 'plgSearchGamesboxsearchAreas' );

JPlugin::loadLanguage( 'plg_search_Gamesboxsearch' );

//Define a function to return an array of search areas. Replace 'nameofplugin' with the name of your plugin.
function &plgSearchGamesboxsearchAreas()
{
        static $areas = array(
                'Gamesboxsearch' => 'Gamesbox'
        );
        return $areas;
}

//The real function has to be created. The database connection should be made.
//The function will be closed with an } at the end of the file.
function plgSearchGamesboxsearch( $text, $phrase='', $ordering='', $areas=null )
{
        $db            =& JFactory::getDBO();
        $user  =& JFactory::getUser();

//If the array is not correct, return it:
        if (is_array( $areas )) {
                if (!array_intersect( $areas, array_keys( plgSearchGamesboxsearchAreas() ) )) {
                        return array();
                }
        }

//Define the parameters. First get the right plugin; 'search' (the group), 'nameofplugin'.
$plugin =& JPluginHelper::getPlugin('search', 'Gamesboxsearch');

//Then load the parameters of the plugin.
$pluginParams = new JParameter( $plugin->params );

//Now define the parameters like this:
//$limit = $pluginParams->def( 'nameofparameter', defaultsetting );

//Use the function trim to delete spaces in front of or at the back of the searching terms
$text = trim( $text );

//Return Array when nothing was filled in.
if ($text == '') {
                return array();
        }

//After this, you have to add the database part. This will be the most difficult part, because this changes per situation.
//In the coding examples later on you will find some of the examples used by Joomla! 1.5 core Search Plugins.
//It will look something like this.
        $wheres = array();
        switch ($phrase) {

//search exact
                case 'exact':
                        $text          = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
                        $wheres2       = array();
                        $wheres2[]   = 'LOWER(a.title) LIKE '.$text;
                        $where                 = '(' . implode( ') OR (', $wheres2 ) . ')';
                        break;

//search all or any
                case 'all':
                case 'any':

//set default
                default:
                        $words         = explode( ' ', $text );
                        $wheres = array();
                        foreach ($words as $word)
                        {
                                $word          = $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false );
                                $wheres2       = array();
                                $wheres2[]   = 'LOWER(a.title) LIKE '.$word;
                                $wheres[]    = implode( ' OR ', $wheres2 );
                        }
                        $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
                        break;
        }

//ordering of the results
        switch ( $ordering ) {

//alphabetic, ascending
                case 'alpha':
                        $order = 'a.title ASC';
                        break;

//oldest first
                case 'oldest':

//popular first
                case 'popular':

//newest first
                case 'newest':

//default setting: alphabetic, ascending
                default:
                        $order = 'a.title ASC';
        }

//replace nameofplugin
        $searchGamesboxsearch = JText::_( 'Nameofplugin' );

//the database query; differs per situation! It will look something like this:
        $query = 'SELECT a.id AS id, a.title AS title, a.preview AS text, '
//        . ' CONCAT_WS( "/", a.title) AS section,'
        . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":",a.alias) END as slug,'
        . ' "0" AS browsernav'
        . ' FROM #__gamesbox_documents AS a'
        . ' WHERE ( '. $where .' )'
        . ' AND a.published = 1'
        . ' ORDER BY '. $order
        ;

//Set query
        $db->setQuery( $query, 0, $limit );
        $rows = $db->loadObjectList();

//The 'output' of the displayed link
        foreach($rows as $key => $row) {
                $rows[$key]->href = 'index.php?option=com_gamesbox&view=document&layout=preview&id='.$row->slug;
        }
//http://www.larp.tv/tv2/component/gamesbox/games/hunted-die-schmiede-der-finsternis
//http://www.larp.tv/tv2/index.php?option=com_gamesbox&view=document&layout=preview&id=1%3Ahunted-die-schmiede-der-finsternis&lang=de
//Return the search results in an array
return $rows;
}

//$rows[] = (object) array(
//                        'href'        => 'component/gamesbox/games/'.$row->slug.'.html',
//                        'title'       => $row['title'],
//                        'release'     => $row['launch_date'],
//                        'producer'     => $row['producer'],
//                        'text'        => $row['preview'],
//                        'browsernav'  => '1'
//                );