Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search plugin (I18N)
geroyche Wrote:Thanks for the quick reply.
Sometimes sleep helps. I did some debugging and I realized that the problem lay elsewhere.
The news manager function i used to fetch posts did not even include the content (it fetched everything else from a sort of "cache" News Manager creates).

Everything works now as it should.

Great!
You should post instructions on how to use your code to the news manager support thread.
One more tip: You could pass array('news', $category) as tags to the indexer, where $category is the category of the news item (I think there is one?). Then you can specifically search for news and categories.

geroyche Wrote:I have one more question though: somehow your index is created everytime a regular page is being saved/updated.
The News Manager items are managed separately.
I reckon I might have to patch its code to trigger an index update.
How do I trigger it?

Just call delete_i18n_search_index(). The index is recreated, when the next search is executed.

geroyche Wrote:FYI: here are the functions as they need be for News Manager. Don't know if you want to include them in your plugin, though I figure I should probably give them to the NM dev instead.
http://pastebin.com/eqXS6XAR

I would upload the plugin for the general public, except that when I store it as a separate php file in my plugin folder, I cannot login anymore. I get stuck in a redirect loop.
I already had another custom plugin, and when I just include the functions in that one, everything works,

You should try to have it included in the news manager.
I specifically created this functionality in the Search plugin to allow other plugins to use this global search instead of implementing a search themselves.

I think, if you include a register_plugin call thus making a regular plugin from it, you should have no problems with loops. If you additionally add checks for the News Manager in your function i18n_search_nm_index - if (!function_exists('nm_get_posts')) return; - your plugin won't crash even if News Manager is not installed.

This shows that it's easy to not only extend GetSimple with plugins, but also to extend plugins themselves.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
I18N Search version 2.4:
  • adds additional parameters addTags and addWords to add tags or words to the user input.
  • allows the configuration of a transliteration of characters for search, e.g. type "slowo", find "słowo" ("ł" to "l" conversion) (@CyberDe@th)
  • output closing </li> for search results displayed with a custom component
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
I've tried custom rendering, but with the sample (default way) component I get this:
Quote:Notice: Undefined variable: dateFormat in [...]/plugins/i18n_search/searchresults.php(4) : eval()'d code on line 10

Notice: Undefined variable: numWords in [...]/plugins/i18n_search/searchresults.php(4) : eval()'d code on line 13
That is, with debug mode enabled. Dates and excerpts are not rendered, only lang, link and page title.

Did I miss something?
Reply
Is there a way to remove (not hide) the Search Results title/header:
Code:
<h2 class="search-header">Search Results</h2>
when using (% searchresults ... %) in a page?

(sorry if it has been asked before, I couldn't find anything about this...)
Reply
Carlos Wrote:Is there a way to remove (not hide) the Search Results title/header:
Code:
<h2 class="search-header">Search Results</h2>
when using (% searchresults ... %) in a page?

(% searchresults HEADER= %)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
I18N Search version 2.4.1:
  • fixes a problem with the use of components for displaying search results (@Carlos)
  • improves the tag cloud, if addTags: only the tags occuring in pages with the addTags are displayed
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Thanks. Works perfect.
Reply
Suggestion:
(% searchresults parent=myparent ... %)

If you wish to implement this, it also would be fine being able to select the current parent ( parent=., parent=0, ...?)
Reply
Another suggestion:
(% searchresults ... order=title %)

This is an easy one, ;-) I patched searcher.class.php myself (inserted a bit of code in line 400's switch and a new function compare_title()) to do this.
Reply
Carlos Wrote:Suggestion:
(% searchresults parent=myparent ... %)

If you wish to implement this, it also would be fine being able to select the current parent ( parent=., parent=0, ...?)

If you want to get the children of a page, you can use the I18N navigation functions.
Or give a unique tag to all these child pages - this can be simplified by using the new I18N Special Pages plugin.

Currently I do not plan to extend the searching capabilities of I18N Search beyond words and tags.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Carlos Wrote:Another suggestion:
(% searchresults ... order=title %)

This is an easy one, ;-) I patched searcher.class.php myself (inserted a bit of code in line 400's switch and a new function compare_title()) to do this.

I didn't implement this, because the title is not held in the index files (as opposed to the date, slug, as it is the page key, and the score, which is calculated). For large sites and searches with lots of results that would mean that lots of page xmls are accessed instead of only those on the first result page.

However, for most sites it shouldn't make much difference. I'll include it in the next release.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Issue: in excerpts, &nbsp; is rendered as �
Reply
Carlos Wrote:Issue: in excerpts, &nbsp; is rendered as �

Works for me. Maybe you don't display your page in UTF-8?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Hi!

I get the following when I try to implement the searchform:
Code:
Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11

Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11
(% searchform slug:'search' ajax:0 showtags:0 %)

(% searchresults %)

Any idea what's causing this?
Reply
AsgeirSH Wrote:Hi!

I get the following when I try to implement the searchform:
Code:
Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11

Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11
(% searchform slug:'search' ajax:0 showtags:0 %)

(% searchresults %)

Any idea what's causing this?

Never had this before.
Try to change line 76 private static function replaceContentMatch to public static function replaceContentMatch.
Which version of PHP are you using? Which operating system?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:Works for me. Maybe you don't display your page in UTF-8?

No, it's UTF-8. But I've tried in a live server and doesn't happen. So it may be something wrong in my local site (will reinstall XAMPP some day).
Thanks.
Reply
Carlos Wrote:
mvlcek Wrote:Works for me. Maybe you don't display your page in UTF-8?

No, it's UTF-8. But I've tried in a live server and doesn't happen. So it may be something wrong in my local site (will reinstall XAMPP some day).
Thanks.

Maybe the multibyte string (mbstring) PHP extension is not installed (http://www.php.net/manual/en/mbstring.installation.php).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:
AsgeirSH Wrote:Hi!

I get the following when I try to implement the searchform:
Code:
Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11

Warning: preg_replace_callback() [function.preg-replace-callback]: Unable to call custom replacement function in /store/1/web/hkmedia.no/plugins/i18n_search/viewer.class.php on line 11
(% searchform slug:'search' ajax:0 showtags:0 %)

(% searchresults %)

Any idea what's causing this?

Never had this before.
Try to change line 76 private static function replaceContentMatch to public static function replaceContentMatch.
Which version of PHP are you using? Which operating system?

Changing it to public had no effect. Running Apache on a Linux-server. (Linux server33 2.4.37.5-ow1-ip, Apache Release 10337100 )

A sidenote is that ZipArchive is not installed on the server, although I can't imagine that would matter for this plugin?
Reply
Hey guys, is there any way I can add I18N gallery into I18N search results?
Reply
Please take a look here: http://www.graf1x.com/index.php?id=news

The cropped pictures from the gallery show up, even links work, but the alignment and JS is not working.
I managed to display pictures by putting these two lines:

(% gallery type=prettyphoto autostart=true %)
(% searchresults tags:news numWords:-50 order:reverseurl %)
Reply
avoleoo Wrote:Please take a look here: http://www.graf1x.com/index.php?id=news

The cropped pictures from the gallery show up, even links work, but the alignment and JS is not working.
I managed to display pictures by putting these two lines:

(% gallery type=prettyphoto autostart=true %)
(% searchresults tags:news numWords:-50 order:reverseurl %)

Showing galleries in the search results is generally not possible.

But if all your galleries have the same properties, you can create a special page template for the search result page and add something like <?php get_i18n_gallery_header('my-gallery', array('type'=>'prettyphoto', 'autostart'=>true)); ?> to its header. This should set the appropriate styles and load the JS files.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:
avoleoo Wrote:Please take a look here: http://www.graf1x.com/index.php?id=news

The cropped pictures from the gallery show up, even links work, but the alignment and JS is not working.
I managed to display pictures by putting these two lines:

(% gallery type=prettyphoto autostart=true %)
(% searchresults tags:news numWords:-50 order:reverseurl %)

Showing galleries in the search results is generally not possible.

But if all your galleries have the same properties, you can create a special page template for the search result page and add something like <?php get_i18n_gallery_header('my-gallery', array('type'=>'prettyphoto', 'autostart'=>true)); ?> to its header. This should set the appropriate styles and load the JS files.


Thanks mvlcek, It worked out well, but the only thing is that every time I will want to post new gallery I will have to add syntax to header of the special page, right? Is there any way around?
Reply
I18N Search version 2.5:
  • adds live search functionality (for an example see here).

To use live search, just add live=1 to search form and results:
Code:
(% searchform live=1 %)
(% searchresults HEADER='' live=1 %)
This creates additional requests during search entry - make sure your server is sufficiently fast.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:Currently I do not plan to extend the searching capabilities of I18N Search beyond words and tags.

Could it be possible that when page is indexed, its parent is added as a (virtual) tag like _parent_{SLUG}, so that you can do:
Code:
(% searchresults tags=_parent_myparent ... %)

Do you think there is a way to do this without patching the indexer? (I think there's some hook or filter in the plugin, but don't know if it can be used for this...)
Reply
Carlos Wrote:Could it be possible that when page is indexed, its parent is added as a (virtual) tag like _parent_{SLUG}

That's a great idea! It's implemented in
I18N Search version 2.6:
  • a virtual tag _parent_parent-slug is added to the search index

You can list all direct children of a page e.g. products with
Code:
(% searchresults tags=_parent_products %)
or limit a user's search to these pages with
Code:
(% searchform %)
(% searchresults addTags=_parent_products %)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 2 Guest(s)