SearchPhp - Pimcore Website Search

Support for extensions in the extension hub.
Post Reply
Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

SearchPhp - Pimcore Website Search

Post by Noviomagus » Thu Jan 12, 2012 11:51 pm

Hey there,
have anyone an Example how i can integrate an Frontendsearch with Search PHP in my Pimcore Site ?

the only one i can found is this script Line:
<?= $this->action("find", "frontend", "SearchPhp", array())?>

Thanks!

Johannes

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Fri Jan 13, 2012 8:59 am

Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 11:26 am

In the Documentation i found only:

"the search plugin comes with a ready to use search frontend. The following code snippet needs to be included in the view script of the search result page.

<?= $this->action("find", "frontend", "SearchPhp", array())?>"

Thats don't run ...

"Fatal error: Uncaught exception 'Exception' with message 'could not open index' in........... "

Have anybody an idea ?

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Fri Jan 13, 2012 11:37 am

Well, there's not very much more to it.

Configure the plugin as needed in it's options menu.
The crawler is hooked to the maintanance script that's supposed to be run with a cron job.

The line

Code: Select all

<?= $this->action("find", "frontend", "SearchPhp", array())?>

integrates the search field in your frontend. The result page is called automatically and, of course, equipped with your layout - if you defined one.

If you need to change the looks of the result page set the viewscript in above quoted line and have a look at SearchPhp/views/scripts/frontend/find.php to see how a resultpage needs to be done.

Also have a look at viewtopic.php?f=15&t=256 there're some fixes for the current release of the plugin.
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Fri Jan 13, 2012 11:47 am

Didn't see that, did you edit this?
Noviomagus wrote:Thats don't run ...

"Fatal error: Uncaught exception 'Exception' with message 'could not open index' in........... "

Have anybody an idea ?


That can have several reasons:
1) The crawler didn't run yet. Please check the plugin's settings in the options menu, also check the logs and try at least one to run pimcore's maintanace script manually (su - apache (or whatever), cd /var/www/whatever/pimcore/cli, php maintanace,php, ask again if you can't figure out what to do) with the setting to force-run the crawler
2) The Index isn't readable. Check website/var/search/frontend if the directories are accessable by the webserver
3) If the crawler works without an error an the index won't show up at all your webserver isn't allowed to call php's "execute" function.

In this case you need to apply a workaround.

Modify SearchPhp/lib/SearchPhp/Plugin.php.
Add these methods:

Code: Select all

    protected function rrmdir($dir) {
        if (is_dir($dir)) {
            $files = scandir($dir);
            foreach ($files as $file) if ($file != "." && $file != "..") $this->rrmdir("$dir/$file");
            rmdir($dir);
        }
        else if (file_exists($dir)) unlink($dir);
    }

    // copies files and non-empty directories
    protected function rcopy($src, $dst) {
      //if (file_exists($dst)) $this->rrmdir($dst);
      if (is_dir($src)) {
        mkdir($dst);
        $files = scandir($src);
        foreach ($files as $file)
            if ($file != "." && $file != "..") $this->rcopy("$src/$file", "$dst/$file");
      }
      else if (file_exists($src)) copy($src, $dst);
    } 


Find

Code: Select all

exec("rm -Rf " . str_replace("/index/", "/tmpindex", $indexDir));

Change it to:

Code: Select all

$this->rrmdir(str_replace("/index/", "/tmpindex", $indexDir));


Find

Code: Select all

exec("rm -Rf " . $indexDir);

Change it to:

Code: Select all

$this->rrmdir($indexDir);


Find

Code: Select all

exec("cp -R " . substr($tmpIndex, 0, -1) . " " . substr($indexDir, 0, -1));

Change it to:

Code: Select all

$this->rcopy(substr($tmpIndex, 0, -1), substr($indexDir, 0, -1));


I hope that helps.
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 12:02 pm

Hey Thomas,
first thanks for your many Replays ...


Also ... i have a look and the Problem iss the Crawler, Maintrance Cron is running but i put the Start Button and after the Maintrance Cron there is unput.

I have correctly define the Values in the Plugin Config:

the Test-Site running under a Subdomain:
admin.commdesigner.com

as Value for Start-URLs for crawler *:
i have take: http://admin.commdesigner.com

as Regexes for valid URIs *:
i have take: @^http://www\.admin.commdesigner\.com.*@i

Thats all or ?

PS: the last Post i don't see but i test it now ... THAAAAAAAAAAAAANks a lot !

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 1:00 pm

OK the easyrer Way the Ecec on the Server to Activate dont runs too ...
no i test the way with the Code Korrektions ...

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 1:58 pm

OK ... i have make the Changes in the " SearchPhp/Plugin.php."
The Crawler startet for 20 Sek then it stopped an going in Off mode.

Have anybody an idea whats the Problem is ?

The Entries "Start-URLs for crawler *:"
and
"Regexes for valid URIs *:"

i have set correctly ...



Where i can find an Error Log ?
In the System Log are no Messages ...

???

Thanks for Help anyone ...

Bildschirmfoto 2012-01-13 um 13.00.19.jpg

Bildschirmfoto 2012-01-13 um 13.00.19.jpg
Attachments
Bildschirmfoto 2012-01-13 um 13.00.12.jpg

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Fri Jan 13, 2012 2:31 pm

Noviomagus wrote:Where i can find an Error Log ?
In the System Log are no Messages ...


Try to run the Maintanace Script by Hand, with activated Crawler:
Attachments
maintanace_cli.png
maintanace_cli.png (8.15 KiB) Viewed 21418 times
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 5:01 pm

Hey Thomas,
thanks for Response, i have an Managed Server without an Terminal-Access. The Maintenance Script is running, thats checked.

Noviomagus
Posts: 21
Joined: Fri Nov 25, 2011 10:17 pm

Re: SearchPhp - Pimcore Website Search

Post by Noviomagus » Fri Jan 13, 2012 9:39 pm

Hey Thomas,

have you any otherone Idea ....

in the Log file i have the foloing Informations ...

2012-01-13T20:50:11+01:00 INFO (6): Schedule_Manager_Daemon->run() [76]: finished Jobs, all child threads are done.
2012-01-13T20:50:11+01:00 DEBUG (7): Schedule_Manager_Daemon->launchJob() [112]: Done with job [ SearchPhp_Plugin ]
2012-01-13T20:50:11+01:00 INFO (6): SearchPhp_Plugin->frontendCrawl() [501]: SearchPhp_Plugin: Finished crawl
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Plugin->frontendCrawl() [500]: SearchPhp_Plugin: replaced old index
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Plugin->frontendCrawl() [499]: cp -R /var/customers/webs/Noviomagus/pc_multisite/htdocs/website/var/search/frontend/tmpindex /var/customers/webs/Noviomagus/pc_multisite/htdocs/website/var/search/frontend/index
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Plugin->frontendCrawl() [496]: rm -Rf /var/customers/webs/Noviomagus/pc_multisite/htdocs/website/var/search/frontend/index/
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Plugin->frontendCrawl() [488]: SearchPhp_Plugin: replacing old index ...
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Frontend_Crawler->findLinks() [205]: SearchPhp_Frontend_Crawler: Closed frontend index references
2012-01-13T20:50:11+01:00 DEBUG (7): SearchPhp_Frontend_Crawler->doIndex() [267]: SearchPhp_Frontend_Crawler: Added to lucene index db entry id [ 13 ]
2012-01-13T20:50:07+01:00 DEBUG (7): Pimcore_Resource_Mysql::getConnection() [57]: Successfully established connection to MySQL-Server
2012-01-13T20:50:07+01:00 DEBUG (7): Pimcore_Resource_Mysql::getConnection() [57]: Successfully established connection to MySQL-Server
2012-01-13T20:50:07+01:00 INFO (6): Schedule_Manager_Daemon->run() [76]: finished Jobs, all child threads are done.
2012-01-13T20:50:07+01:00 DEBUG (7): Schedule_Manager_Daemon->launchJob() [112]: Done with job [ crawler-8 ]

2012-01-13T20:50:07+01:00 ERR (3): call_user_func_array() []: SearchPhp_Frontend_Crawler: Error parsing [ http://www.sappwork.de/news/live-demo-a ... disabled=1 ]
#3 {main}



The Crawler working for a view Seconds and Stop then.

Thanks too ...

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Sat Jan 14, 2012 4:34 pm

THe Problem is that the crawler is a CLI script, and unless you can't run it on the command line to make sure there're not any errors involving the CLI environment there's probably no way to tell where the error is.

You could try to run the maintanance script as a http-request to see what's happening, but I currently don't know how to do that, and it won't show any errors involving the real CLI.

Sorry - without real debugging it'll be very hard to find the problem :(
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

alexandr
Posts: 13
Joined: Wed Dec 19, 2012 9:20 pm

Re: SearchPhp - Pimcore Website Search

Post by alexandr » Wed Dec 19, 2012 9:28 pm

thomas wrote:Well, there's not very much more to it.

Configure the plugin as needed in it's options menu.
The crawler is hooked to the maintanance script that's supposed to be run with a cron job.

The line

Code: Select all

<?= $this->action("find", "frontend", "SearchPhp", array())?>

integrates the search field in your frontend. The result page is called automatically and, of course, equipped with your layout - if you defined one.

If you need to change the looks of the result page set the viewscript in above quoted line and have a look at SearchPhp/views/scripts/frontend/find.php to see how a resultpage needs to be done.

Also have a look at viewtopic.php?f=15&t=256 there're some fixes for the current release of the plugin.



Dear Thomas! Answer please in what file to place this line: <?= $this->action("find", "frontend", "SearchPhp", array())?> . I tried many options, but I don't display a form for search on a site. Thanks in advance!

User avatar
thomas
Posts: 251
Joined: Tue Aug 09, 2011 9:23 am
Location: Kaufbeuren, Germany
Contact:

Re: SearchPhp - Pimcore Website Search

Post by thomas » Mon Jan 07, 2013 10:40 am

alexandr wrote:Answer please in what file to place this line: <?= $this->action("find", "frontend", "SearchPhp", array())?> . I tried many options, but I don't display a form for search on a site. Thanks in advance!


You place this line either in a view script or, if you want to have it globally, in your layout.
Weblizards - Custom Internet Solutions: http://www.weblizards.de/
pimcore professional partner

kovinet
Posts: 36
Joined: Thu Nov 22, 2012 3:37 pm

Re: SearchPhp - Pimcore Website Search

Post by kovinet » Wed May 20, 2015 3:20 pm

Is there maybe update of this module for Pimcore 3.0 somewhere? I installed it with composer but it's not working anymore in 3.0.

Cruiser
Posts: 73
Joined: Wed Jun 11, 2014 12:53 pm

Re: SearchPhp - Pimcore Website Search

Post by Cruiser » Mon Jun 01, 2015 4:33 pm


Post Reply

Return to “Extension Support”



Who is online

Users browsing this forum: No registered users and 1 guest