Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search plugin (I18N)
#1
My I18N Search plugin (http://get-simple.info/extend/plugin/i18n-search/82/) allows you to search for tags (keywords) and words. It uses an automatically created index and orders the results by relevancy (number of occurences, title is more important than content, etc.).

Each result entry includes the title, the language (if used together with the I18N plugin), the date and an excerpt of the page. It can be styled with CSS or the results can be retrieved as array, in which case you are responsible for creating the HTML.

The plugin is fully configurable and optimized to work on multi-language sites together with the I18N plugin (http://get-simple.info/extend/plugin/i18n/69/), but will also work standalone.

Installation

Unzip the plugin (http://get-simple.info/extend/plugin/i18n-search/82/) to your plugins directory.

Include jQuery in your template, unless you use the simple search form with
Code:
(% searchform showTags:0 ajax:0 %)

Usage

Create a page with slug/URL 'search' (or any other name) and include the following text:

Code:
(% searchform %)
(% searchresults %)

Go to this page and search.

You can use this plugin to display news and to generate RSS feeds.

To (additionally) include a search form in the template (which uses the 'search' page to display the results), use

Code:
<?php get_i18n_search_form(array('slug'=>'search', 'showTags'=>0)); ?>

For more information see the configuration page (Plugins/Configure I18N Search) in the Admin back-end.
Also see I18N Search, I18N Search for News & Blogs and Generate RSS feeds with I18N Search.

Example

See http://mvlcek.bplaced.net/search for an example.

For Developers of other plugins

Version 2.0+ supports indexing of custom fields (see I18N Custom Fields) and of other non-page data (plugin developers: see attached example plugin - i18n_search_dummy.zip).


Attached Files
.zip   i18n_search_dummy.zip (Size: 1.54 KB / Downloads: 75)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
Update: INVALID as of version 1.0

The I18N Search plugin now provides functions to display all tags in a size proportional to their frequency. For a enhanced search where the user can select tags, include the following in your template or (with the DynPages plugin) a component:

Code:
<form action="<?php echo find_url('search', null); ?>">
  <div class="tags"><?php get_i18n_tags(60,250); ?></div>
  <input type="hidden" name="tags" value="<?php echo htmlspecialchars(@$_REQUEST['tags'])?>"/>
  <input type="text" name="words" value="<?php echo htmlspecialchars(@$_REQUEST['words'])?>"/>
  <input type="submit" name="search" value="Go" />
</form>
<script type="text/javascript">
  $(function() {
    $('.tags .tag').click(function(e) {
      $(e.target).toggleClass('selected');
      var tags = ''
      $('.tags .tag.selected').each(function() { tags += ' '+$(this).text(); });
      $('[name=tags]').val(tags);
    });
    var tags = $('[name=tags]').val().split(' ');
    $('.tags .tag').each(function() {
      if ($.inArray($(this).text(),tags) >= 0) $(this).addClass('selected');
    });
  })
</script>
<br />
<?php
  if (isset($_REQUEST['search'])) {
?>
<h2>Search Results</h2>
<?php  
    get_i18n_search_results(null, null, 'No results found' , 'l, F jS, Y - g:i A', 10, 30);
  }
?>

An example can be found on http://mvlcek.bplaced.net/search
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Why can not I search? what did I do wrong?
http://neowebtime.ru/01/search
Reply
#4
Oleg06 Wrote:Why can not I search? what did I do wrong?
http://neowebtime.ru/01/search

It seems, it only finds words with ASCII characters, not even german äöü.
I'll look into it.

Regarding searching for tags: "_pagify 2000" is one tag, but searching for tags with blanks is not supported. A newer version of search will ignore all tags with _ in the beginning.

Thanks for testing.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#5
@Oleg06: I've uploaded a new version of the plugin which will index the site correctly, if your php has multibyte strings enabled. Please test.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
Don't forget to delete data/other/i18n_*_index.txt or change/save a page.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#7
works in all languages, cool
Reply
#8
Thanks to the developer of this plugin. Sorely missed. You are simply the best.
Reply
#9
Hi

awesome plugin, but...

I'm using GS 2.01 and have problems to install DynPlaces plugin...anyone knows how fix that?


regards
Reply
#10
I put this code
Code:
get_i18n_search_results($tags=null, $words=null,
    $notfoundtext='No results found!', $dateformat='l, F jS, Y - g:i A',
    $max=10, $excerptlength=30)
and get this
Code:
Notice: Undefined offset: 3 in /home/cp068800/public_html/neowebtime.ru/01/plugins/dynpages.php on line 47

Parse error: syntax error, unexpected '}' in /home/cp068800/public_html/neowebtime.ru/01/plugins/i18n.php(366) : eval()'d code on line 30
http://neowebtime.ru/01/search
Reply
#11
Oleg06 Wrote:I put this code
Code:
get_i18n_search_results($tags=null, $words=null,
    $notfoundtext='No results found!', $dateformat='l, F jS, Y - g:i A',
    $max=10, $excerptlength=30)

That's the function definition. To call it you should use something like get_i18n_search_results(null, null, 'No results found!', 'l, F jS, Y - g:i A', 10, 30) into your component or your template (within <?php ... ?> tags).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#12
I put this code in the component search
Code:
<form action="<?php echo find_url('search', null); ?>">
  <div class="tags"><?php get_i18n_tags(60,250); ?></div>
  <input type="hidden" name="tags" value="<?php echo htmlspecialchars(@$_REQUEST['tags'])?>"/>
  <input type="text" name="words" value="<?php echo htmlspecialchars(@$_REQUEST['words'])?>"/>
  <input type="submit" name="search" value="Go" />
</form>
<script type="text/javascript">
  $(function() {
    $('.tags .tag').click(function(e) {
      $(e.target).toggleClass('selected');
      var tags = ''
      $('.tags .tag.selected').each(function() { tags += ' '+$(this).text(); });
      $('[name=tags]').val(tags);
    });
    var tags = $('[name=tags]').val().split(' ');
    $('.tags .tag').each(function() {
      if ($.inArray($(this).text(),tags) >= 0) $(this).addClass('selected');
    });
  })
</script>
<br />
<?php
  if (isset($_REQUEST['search'])) {
?>
<h2>Search Results</h2>
<?php  
    get_i18n_search_results($tags=null, $words=null,
    $notfoundtext='No results found!', $dateformat='l, F jS, Y - g:i A',
    $max=10, $excerptlength=30)
  }
?>
Reply
#13
A new version (http://get-simple.info/extend/plugin/i18n-search/82/) is available:
  • new function to output a search form with or without tag cloud
  • added paging for the search results
  • cleaner API

Attention: The function parameters have changed, see http://mvlcek.bplaced.net/get-simple/i18nsearch/

Usage:

Output search form (calling page 'search') with a tag cloud with font sizes from 60 to 250%:

Code:
<?php get_i18n_search_form('search', 60, 250); ?>

Output search results with paging, getting parameters from request, paging, 10 results per page and 30 words as excerpt:

Code:
<?php get_i18n_search_results(null, null, null, 10, 30);  ?>

For customization and a more detailed description see http://mvlcek.bplaced.net/get-simple/i18nsearch/, for an example see http://mvlcek.bplaced.net/search/.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#14
Oh, and this plugin will function normally
how to remove the tag on the form?
Reply
#15
Oleg06 Wrote:Oh, and this plugin will function normally
how to remove the tag on the form?

To show a form without tag cloud, use null as minimum/maximum font sizes:

Code:
<?php get_i18n_search_form('search', null, null); ?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#16
Hi, I search plugin works and look for results, but does not seek texts on the Dominion blog (plugin). I make mistakes or not it is connected? Thank you.
Reply
#17
astherix Wrote:Hi, I search plugin works and look for results, but does not seek texts on the Dominion blog (plugin).

The search plugin indexes all pages of the installation, but the Dominion blog does not store the news as pages but in a separate file.

In my opinion every piece of content on a CMS should be stored in the same way, only differing by the metadata. For example the news on my site http://mvlcek.bplaced.net are normal pages with a slug/URL with date and time like news-20110114-1235 and as parent the page news. Additionally they get the tag/keyword _news.

On the news page I just use a search for all content with tag _news. It's automatically sorted with the newest news first.

I plan on updating the I18N plugin so that you can configure it to exclude certain pages and their children (to exclude the news) and creating a plugin which will simplify news entry:
  • admin: list the news ordered by date, grouping them by year and month, if their are too many.
  • admin: create a news item and automatically set the tag, slug and parent
  • provide a news list where the first paragraph and possibly the first picture of the news item is displayed
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#18
what does this line http://neowebtime.ru/01/news-i18n
Code:
Warning: Division by zero in /home/cp068800/public_html/neowebtime.ru/01/plugins/i18n_search.php on line 395

as a calendar display as 03/02/2001 15.44?

how to limit the amount of news on one page, and whether the pagination?
Reply
#19
Oleg06 Wrote:what does this line http://neowebtime.ru/01/news-i18n
Code:
Warning: Division by zero in /home/cp068800/public_html/neowebtime.ru/01/plugins/i18n_search.php on line 395

as a calendar display as 03/02/2001 15.44

The call syntax changed in the last release of the search plugin and you probably still use the old one. If you used something like

Code:
get_i18n_search_results(searchTags, searchWords, notfoundText, dateFormat, maxItemsToDisplay, numberOfExcerptWords)

you must now use

Code:
set_i18n_search_texts(searchbuttonText, notfoundText, dateFormat);
get_i18n_search_results(searchTags, searchWords, indexOfFirstItemToDisplay, maxItemsToDisplay, numerOfExcerptWords);

where searchTags and searchWords are normally null to be taken from the request and indexOfFirstItemToDisplay should be null if you want paging.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#20
I put in the sidebar
Code:
<?php get_i18n_search_form('search', 60, 250); ?>
to search page I put
Code:
<?php get_i18n_search_results(null, null, null, 10, 30); ?>
to news page I put
Code:
<?php get_i18n_search_results('news', null, 'No news found', 'l, F jS, Y - g:i A', 15, -1); ?>
plugin I downloaded yesterday

:-)
send me the complete code, which I will put on the news page, to display the calendar in the format dd / mm / year, to be displayed on the page 3 news and a pagination
Reply
#21
The search in your side bar works. The page that doesn't work, seems to be the news page/component/template (.../news-i18n), where you also call the search function - still with the old syntax?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#22
in the sidebar I have a different plugin of news

:-)
send me the complete code, which I will put on the news page, to display the calendar in the format dd / mm / year, to be displayed on the page 3 news and a pagination
Reply
#23
Oleg06 Wrote:send me the complete code, which I will put on the news page, to display the calendar in the format dd / mm / year, to be displayed on the page 3 news and a pagination

assuming your tag for news is 'news' and you want to see the complete news content (last parameter -1), with date and time (without time use just 'd/m/Y', other formats see http://php.net/manual/de/function.date.php):

Code:
<?php
set_i18n_search_texts('Search',  'No news found', 'd/m/Y H:i');
get_i18n_search_results('news', null, null, 3, -1);
?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#24
http://neowebtime.ru/01/news-i18n
Code:
Parse error: syntax error, unexpected '>' in /home/cp068800/public_html/neowebtime.ru/01/plugins/exec-php.php(33) : eval()'d code on line 2
Reply
#25
if not insert into the text, but in the code, everything works, but the code is not stored on the news page
http://neowebtime.ru/01/blog
Reply




Users browsing this thread: 3 Guest(s)