Topic Closed

I want to the search into special link html output.

Out of the box plugin output was not include into the gpeasy search function.

I've play arround with the search hook:

;Addon_Name
Addon_Name = 'Test'    

;Addon_Unique_ID
Addon_Unique_ID = 676

;Addon_Version
Addon_Version = 0.4

;min_gpeasy_version
min_gpeasy_version = 1.5RC2

;A description about your addon,
; may contain some html: <div>,<p>,<a>,<b>,<br/>,<span>,<tt>,<em>,<i>,<b>,<sup>,<sub>,<strong>,<u>
About = 'Test';

[Special_Link:ELMA diag system]
label = 'System diag'
script = 'system.php'
;class = 'Configuration'

[Special_Link:ELMA diag rsyslog]
label = 'rsyslog diag'
script = 'rsyslog.php'
;class = 'Configuration'

[Search]
script = 'Search.php'
class = 'DiagSearch'

My tries with search.php:

<?php defined('is_running') or die('Not an entry point...');

class DiagSearch{
    function DiagSearch($args){

        $search_obj = $args[0];

        $PluginFile = '/srv/www/htdocs/elma/addons/ELMA Diagnostics/system.php';

        $diagtitle = "Diagnostics";
        $diaglink="ELMA_diag_system";

            $diaglabel = common::GetLabel($diagtitle);
            include($PluginFile);
            $diagcontent = ob_get_clean();

            $search_obj->FindString($diagcontent, $diaglabel, $diaglink);

    }
}
?>

This finds the search pattern, but in case of not matching search pattern it is also in hit list.

Is there a more dynamic way to address all defined special link inside a plugin?

Any help would be fine.

Joerg

5 years ago#7115

fly06
263 Posts
17.6K Downloads
1 Themes
8 Plugins

$diagcontent = ob_get_clean();

Now $diagcontent contains the gpEasy buffer content which itself contains the html code echo-ed by the special_gpsearch::Search() method including the search string.

This explains why your content is always returned in the search results whether it matches the search pattern or not.

I don't know what is the content of your system.php file but assuming it echo-es your plugin html content, adding an ob_start(); instruction just before the include should do the trick.

ob_start();
include($PluginFile);
$diagcontent = ob_get_clean();

 

Edited: 5 years ago#7116

This procedure works fine if in plugin code is no class defined.

But if there are classes the content value becomes empty.

I've tested with Plugins_Examples:

;Map Example
[Special_Link:Example_Map]
label = 'Example_Map'
script = '01_Map.php'
class = 'Example_Map'

;Ajax Example
[Special_Link:Example_Ajax]
label = 'Example_Ajax'
script = '02_Ajax.php'
class = 'Example_Ajax'

[Search]
script = 'Search.php'
class = 'Example_Search'

 

<?php

defined('is_running') or die('Not an entry point...');

class Example_Search {

    function PluginSearchContent($File){

        if( file_exists($File) ){
echo $File."<br>";
            ob_start();
            include($File);
            $Content = ob_get_clean();
        }
        return $Content;
    }

    function Example_Search($args){

        global $addonPathCode;
        $search_obj = $args[0];

        $Label = "Example_Map";
        $Link="Example_Map";
        $File = $addonPathCode.'/01_Map.php';
        $search_obj->FindString($this->PluginSearchContent($File), $Label, $Link);

        $Label = "Example_Ajax";
        $Link="Example_Ajax";
        $File = $addonPathCode.'/02_Ajax.php';
        $search_obj->FindString($this->PluginSearchContent($File), $Label, $Link);
    }
}
?>

 

 

5 years ago#7120

fly06
263 Posts
17.6K Downloads
1 Themes
8 Plugins

Have a look at the Search.php file shipped with Simple_Blog.

It's a good example of how a plugin can be integrated within the gpeasy search feature.

https://gpeasy.com/Plugins/17_Simple_Blog

5 years ago#7136

Topic Closed

 

News

Typesetter 5.1
8/12/2017

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register