Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated to add the Tag-Index feature. Now tags are indexed based on e…

…ntry-categories. One can retrieve tags based on one or more category(s)
  • Loading branch information...
commit 6eacee09f25708c01e5fd81929740a6ddbcf5301 1 parent 9174056
Arvind Tripathy authored
View
36 plugins/SphinxSearch/README.TAG-INDEX
@@ -0,0 +1,36 @@
+::README for SphinxTags::
+
+A complex plugin that relates Tags to Categories. Yes, for some reason we were urged to associate these two entities and return a tag-cloud based on a category.
+
+::Administration::
+1. Verify if Sphinx is actually installed and running correctly on the server
+2. Verify that the SphinxSearch MT plugin is deployed
+3. After installing this plugin to your MT, visit CMS->Settings->Plugins->SphinxSearch
+4. Download latest copy of sphinx.conf and merge with existing if you've made changes to prior sphinx.conf
+5. Run the sphinx indexer with the --rotate option to read the latest data
+6. Test the sphinx indexes for tags by the following command:
+ /path/to/sphinx/search -c /path/to/sphinx/files/sphinx.conf -i tag_index TAG_SEARCH_TERM
+
+
+::Configuration::
+1. Visit your Blog CMS and edit the sidebar widget that renders the tag-cloud
+2. Replace the current tag-cloud lines with the following:
+
+ <mt:Unless name="datebased_archive">
+ <mt:IfArchiveType archive_type="Category">
+ <mt:setvarblock name='cat_name'><mt:ArchiveTitle></mt:setvarblock>
+ </mt:IfArchiveType>
+ </mt:Unless>
+ <mt:setvarblock name='my_blog'><mt:BlogId></mt:setvarblock>
+ <mt:SphinxTagPool category="$cat_name" blog_ids="$my_blog">
+
+3. Copy over one of the templates found in this SphinxTags/tmpl/ folder.
+ tagcloud.tmpl => renders the simple cloud with some CSS formatting
+ tagsearch.tmpl => simple FORM based tag search
+ (it doesn't harm to copy both)
+4. Edit the mt-config.cgi and add the chosen template from the previous step
+
+ SearchAltTemplate tagcloud tagcloud.tmpl
+
+5. Rebuild the Category Archives or the entire site based on where you expect the Tag Clouds to show up.
+6. Sit back, enjoy your blog.
View
10 plugins/SphinxSearch/config.yaml
@@ -1,7 +1,7 @@
id: SphinxSearch
name: SphinxSearch
description: Alternative search engine in MT using SphinxSearch
-version: 0.200
+version: 0.201
author_name: Six Apart, Ltd.
author_link: http://www.sixapart.com/
@@ -126,6 +126,10 @@ tags:
SearchParameters: $SphinxSearch::SphinxSearch::Tags::search_parameters_tag
SearchDateStart: $SphinxSearch::SphinxSearch::Tags::search_date_start_tag
SearchDateEnd: $SphinxSearch::SphinxSearch::Tags::search_date_end_tag
+
+ # special tag
+ SphinxTagPool: '$SphinxSearch::SphinxSearch::Tags::_hdlr_sphinx_tag_pool'
+
block:
IfCurrentSearchResultsPage?: $SphinxSearch::SphinxSearch::Tags::if_current_search_results_page_conditional_tag
IfNotCurrentSearchResultsPage?: $SphinxSearch::SphinxSearch::Tags::if_not_current_search_results_page
@@ -143,6 +147,10 @@ tags:
IfSearchDateStart?: $SphinxSearch::SphinxSearch::Tags::if_search_date_start_conditional_tag
IfSearchDateEnd?: $SphinxSearch::SphinxSearch::Tags::if_search_date_end_conditional_tag
+ # special tags
+ SphinxTags: '$SphinxSearch::SphinxSearch::Tags::_hdlr_sphinx_search_results'
+ SearchResults: '$SphinxSearch::SphinxSearch::Tags::_hdlr_sphinx_search_results'
+
task_workers:
sphinx_indexer_task:
label: "Runs the sphinx indexer."
View
117 plugins/SphinxSearch/lib/SphinxSearch/Config.pm
@@ -48,7 +48,34 @@ sub _get_data_rows {
my @mva_fields;
my @normal_fields;
+ # Do counts first
+ if ( my $counts = $index_hash->{count_columns} ) {
+ for my $count ( keys %$counts ) {
+ my $what_class = $counts->{$count}->{what};
+ my $with_column = $counts->{$count}->{with};
+ my $wheres = $counts->{$count}->{select_values};
+
+ eval("require $what_class;");
+ next if ($@);
+
+ my $terms = {$with_column => $obj->id};
+ if ($wheres) {
+ @$terms{keys %$wheres} = values %$wheres;
+ }
+
+ my $count_val = $what_class->count($terms);
+ next if ($@);
+
+ my %tmp_field;
+ $tmp_field{key} = $count;
+ $tmp_field{value} = $count_val;
+ push @group_fields, \%tmp_field;
+ }
+ }
+
+ # Do regular columns next
foreach(@{ $index_hash->{columns}}) {
+
my %tmp_field;
$tmp_field{key} = $_;
$tmp_field{value} = encode_html($obj->$_);
@@ -77,40 +104,82 @@ sub _get_data_rows {
}
}
+ # Do special and/or mva columns
if ($index_hash->{mva}) {
foreach my $mva ( keys %{ $index_hash->{mva} } ) {
my $cur_mva = $index_hash->{mva}->{$mva};
+ my %tmp_field;
+ $tmp_field{key} = $mva;
- my %terms;
- my $mva_key = "id";
- if ( my $sel_values = $cur_mva->{select_values} ) {
- @terms{keys %$sel_values} = values %$sel_values;
- }
- if( my $id_columns = $cur_mva->{by} ) {
- $terms{$id_columns->[0]} = $obj->id;
- $mva_key = $id_columns->[1];
- } else {
- %terms = ( "${mva}_".$index_hash->{id_column} => $obj->id );
- }
-
- my $mva_source = $cur_mva->{with};
- next if(!$mva_source || $mva_source eq '');
-
- eval("use $mva_source");
+ # This is a hack. XMLPipes and SQL queries
+ if ( my $mva_query = $cur_mva->{query} ) {
+
+ my $mva_class = $cur_mva->{to};
+ $mva_class = $cur_mva->{with} if(!$mva_class);
+ my @cols = @{$cur_mva->{by}};
+
+ eval("require $mva_class;") if($mva_class);
+ next if ($@);
- my @mva_value;
- if($mva_source->can('load')) {
- my @mva_vals = $mva_source->load( \%terms );
- foreach(@mva_vals) {
- push @mva_value, $_->$mva_key;
+ my $driver = $mva_class->dbi_driver;
+ my $dbh = $driver->rw_handle;
+
+ $mva_query .= " AND ".$cols[0]." = ".$obj->id;
+ my $sth = $dbh->prepare($mva_query);
+
+ return 0 if !$sth; # ignore this operation if _meta column doesn't exist
+ $sth->execute or next;
+
+ my $rows;
+ my @mva_value;
+ while (my $row = $sth->fetchrow_arrayref) {
+ $rows++;
+ push @mva_value, $row->[1];
}
- my %tmp_field;
- $tmp_field{key} = $mva;
+ $sth->finish;
+
$tmp_field{value} = join(',',@mva_value);
-
push @mva_fields, \%tmp_field;
+
+ } else {
+
+ my %terms;
+ my $mva_key = "id";
+ if ( my $sel_values = $cur_mva->{select_values} ) {
+ @terms{keys %$sel_values} = values %$sel_values;
+ }
+ if( my $id_columns = $cur_mva->{by} ) {
+
+ # First column is selecting Object column
+ $terms{$id_columns->[0]} = $obj->id;
+
+ # Second column becomes new Join column
+ $mva_key = $id_columns->[1];
+ next if($mva_key !~ /_id/ );
+
+ } else {
+ %terms = ( "${mva}_".$index_hash->{id_column} => $obj->id );
+ }
+
+ my $mva_source = $cur_mva->{with};
+ next if(!$mva_source || $mva_source eq '');
+
+ eval("use $mva_source");
+
+ my %args;
+ my @mva_value;
+ if($mva_source->can('load')) {
+
+ my @mva_vals = $mva_source->load( \%terms, \%args );
+ foreach(@mva_vals) {
+ push @mva_value, $_->$mva_key;
+ }
+
+ $tmp_field{value} = join(',',@mva_value);
+ push @mva_fields, \%tmp_field;
+ }
}
}
}
View
4 plugins/SphinxSearch/lib/SphinxSearch/Search.pm
@@ -16,6 +16,7 @@ sub init_app {
no warnings 'redefine';
*MT::App::Search::execute = sub {
require SphinxSearch::Util;
+
my $results = _get_sphinx_results(@_);
return $_[0]->error( "Error querying searchd: "
. ( SphinxSearch::Util::_get_sphinx_error() || $_[0]->errstr )
@@ -89,7 +90,7 @@ sub _get_sphinx_results {
my $sort_mode = {};
my $sort_mode_param = $app->param('sort_mode') || 'descend';
my $sort_by_param = $app->param('sort_by')
- || ( $index =~ /\bentry\b/ ? 'authored_on' : 'created_on' );
+ || ( $index =~ /\bentry\b/ ? 'authored_on' : ( $index =~ /\btag\b/ ? 'entry_count' : 'created_on' ) );
if ( $sort_mode_param eq 'descend' ) {
$sort_mode = { Descend => $sort_by_param };
@@ -319,6 +320,7 @@ sub _get_sphinx_results {
),
UseDistributed => $distributed,
);
+
return unless ($results);
my $i = 0;
View
137 plugins/SphinxSearch/lib/SphinxSearch/Tags.pm
@@ -4,6 +4,8 @@ package SphinxSearch::Tags;
use strict;
use warnings;
+require MT::Tag;
+
sub search_results_page_loop_container_tag {
my ( $ctx, $args, $cond ) = @_;
@@ -285,20 +287,20 @@ sub search_categories_container_tag {
for my $cat (@cats) {
local $ctx->{__stash}{category} = $cat;
-# Don't think we need all these bits right now
-# local $ctx->{__stash}{entries};
-# local $ctx->{__stash}{category_count};
-# local $ctx->{__stash}{blog_id} = $cat->blog_id;
-# local $ctx->{__stash}{blog} = MT::Blog->load($cat->blog_id, { cached_ok => 1 });
-# my @args = (
-# { blog_id => $cat->blog_id,
-# status => MT::Entry::RELEASE() },
-# { 'join' => [ 'MT::Placement', 'entry_id',
-# { category_id => $cat->id } ],
-# 'sort' => 'created_on',
-# direction => 'descend', });
-# $ctx->{__stash}{category_count} = MT::Entry->count(@args);
-# next unless $ctx->{__stash}{category_count} || $args->{show_empty};
+ # # Don't think we need all these bits right now
+ # local $ctx->{__stash}{entries};
+ # local $ctx->{__stash}{category_count};
+ # local $ctx->{__stash}{blog_id} = $cat->blog_id;
+ # local $ctx->{__stash}{blog} = MT::Blog->load($cat->blog_id, { cached_ok => 1 });
+ # my @args = (
+ # { blog_id => $cat->blog_id,
+ # status => MT::Entry::RELEASE() },
+ # { 'join' => [ 'MT::Placement', 'entry_id',
+ # { category_id => $cat->id } ],
+ # 'sort' => 'created_on',
+ # direction => 'descend', });
+ # $ctx->{__stash}{category_count} = MT::Entry->count(@args);
+ # next unless $ctx->{__stash}{category_count} || $args->{show_empty};
defined( my $out = $builder->build( $ctx, $tokens, $cond ) )
or return $ctx->error( $builder->errstr );
@@ -405,4 +407,111 @@ sub if_last_search_results_page {
!next_search_results_page(@_);
}
+# special tags
+
+# This tag can be used in two ways for now in the Search Results template:
+ # 1) through SeachResults, which it overrides and falls back if no tags were found
+ # 2) specifically through SphinxTags, which is an alternative for search results block
+# Later this can be expanded to more objects returned in the search results that the CORE engine cannot handle
+
+sub _hdlr_sphinx_search_results {
+ my ( $ctx, $args, $cond ) = @_;
+
+ my $tmpltag = lc $ctx->stash('tag');
+
+ # for the case that we want to use mt:Entries with mt-search
+ # send to MT::Template::Search if searh results are found
+ if ($ctx->stash('results') && (!$ctx->stash('sphinxtags') && $tmpltag eq 'searchresults') ) {
+ require MT::Template::Context::Search;
+ return MT::Template::Context::Search::_hdlr_results($ctx, $args, $cond);
+ }
+
+ my @tags = ( @{ $ctx->stash('sphinxtags') } );
+ if(@tags) {
+
+ my $total = scalar(@tags);
+
+ # Initialize the loop variables
+ my $res = ''; # Cumulative output
+ my $count = 0; # Loop counter
+ my $attr = $args->{attributes} || {}; # Tag attributes
+ my $glue = $attr->{glue} || $args->{glue}; # Glue for output
+ my $vars = $ctx->{__stash}{vars} ||= {}; # Template variables
+ my $builder = $ctx->stash('builder'); # Builder objects
+ my $tokens = $ctx->stash('tokens'); # Current template tokens
+
+ for my $tag (@tags) {
+
+ $count++;
+ local $ctx->{__stash}{Tag} = $tag;
+
+ local $vars->{__first__} = $count == 1;
+ local $vars->{__last__} = ($count == $total);
+ local $vars->{__odd__} = ($count % 2) == 1;
+ local $vars->{__even__} = ($count % 2) == 0;
+ local $vars->{__counter__} = $count;
+
+ defined(my $out = $builder->build($ctx, $tokens, $cond))
+ or return $ctx->error( $builder->errstr );
+
+ $res .= $glue if defined($glue) && ( $count > 1 );
+ $res .= $out;
+ }
+ $res;
+ }
+ else {
+
+ # Fall back to standard search results
+ require MT::Template::Context::Search;
+ return MT::Template::Context::Search::_hdlr_results($ctx, $args, $cond);
+ }
+}
+
+# Special function tag to dynamically load a Search URL through jQuery and return the tag-pool based on its parameters.
+# Accepts the following:
+ # div => ID of thne HTML element to load the results in. If not passed it loads in its own DIV by the ID #tagpool
+ # category => comma-delimited list of category basenames to filter the results. Can be single or list of all categories but not meant to be empty
+ # searchall => to return tags always
+ # include_blogs => filter based on one or more blogs
+ # jquery => can be 1, 0 or anything. If not 0, then a link to jQuery is included in the published page statically. Loads from the jQuery host
+
+sub _hdlr_sphinx_tag_pool {
+ my ($ctx, $args) = @_;
+
+ my $div = $args->{div} || 'tagpool';
+ my $cats = $args->{category} || '';
+ my $tmpl = $args->{template} || 'tagcloud';
+ my $searchall = $args->{searchall} || '1';
+ my $blogs = $args->{include_blogs} || $args->{blog_ids}|| '';
+
+ my $load_jquery = $args->{jquery} || '0';
+ $load_jquery = '<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>' if($load_jquery ne '0');
+ $load_jquery = '' if($load_jquery eq '0');
+
+ my $app = MT->instance;
+ my $script = $ctx->{config}->SearchScript;
+
+ my $cgi_path = $app->config('CGIPath');
+ $cgi_path .= '/' unless $cgi_path =~ m!/$!;
+ $cgi_path .= $script;
+
+ my $html = <<HTML;
+
+ $load_jquery
+ <div id="tagpool">
+ <div id="waiting">...</div>
+ </div>
+ <script type="text/javascript">
+ \$(document).ready(function(){
+ \$.get("$cgi_path", { IncludeBlogs: "$blogs", index: "tag", Template: "$tmpl", searchall: "$searchall", category: "$cats", sort_by: "entry_count" },
+ function(data){
+ // alert("Data Loaded: " + data);
+ \$("#$div").html(data);
+ });
+ });
+ </script>
+HTML
+ return $html;
+}
+
1;
View
36 plugins/SphinxSearch/lib/SphinxSearch/Util.pm
@@ -100,6 +100,7 @@ sub init_sphinxable {
query =>
'select distinct mt_comment.comment_id, response_to.comment_commenter_id from mt_comment, mt_comment as response_to where mt_comment.comment_entry_id = response_to.comment_entry_id and mt_comment.comment_created_on > response_to.comment_created_on and response_to.comment_commenter_id is not null',
to => 'MT::Author',
+ by => [ 'comment_id', 'author_id' ],
lookup => 'name',
stash => [ 'author', 'authors' ],
},
@@ -112,6 +113,41 @@ sub init_sphinxable {
}
}
);
+
+ require MT::Tag;
+ require MT::ObjectTag;
+
+ MT::Tag->sphinx_init(
+ index => 'tag',
+ stash => 'sphinxtags',
+ select_values => { is_private => 0 },
+ include_columns => [ 'name' ],
+ count_columns => {
+ entry_count => {
+ what => 'MT::ObjectTag',
+ with => 'tag_id',
+ select_values => { object_datasource => 'entry' }
+ }
+ },
+ mva => {
+ entry => {
+ to => 'MT::Entry',
+ with => 'MT::ObjectTag',
+ by => [ 'tag_id', 'object_id' ],
+ select_values => { object_datasource => 'entry' },
+ },
+ category => {
+ to => 'MT::Category',
+ lookup => 'id',
+ stash => [ 'category', 'categories' ],
+
+ by => [ 'tag_id', 'category_id' ],
+ # remember to allow for the appendage of the columns defined above: by[0] = object_id i.e. tag_id = object_id.
+ # See Config.pm fore more details
+ query => 'select distinct tag_id, placement_category_id from mt_tag, mt_objecttag, mt_placement where tag_id = objecttag_tag_id and objecttag_object_id = placement_entry_id'
+ },
+ }
+ );
}
sub init_apps {
View
2  plugins/SphinxSearch/lib/SphinxSearch/Worker/Indexer.pm
@@ -61,7 +61,7 @@ sub start_searchd {
my $searchd_path = File::Spec->catfile( $bin_path, 'searchd' );
- $job->failed( "Going to start searchd: " . "$searchd_path --config $conf_path" );
+ #$job->failed( "Going to start searchd: " . "$searchd_path --config $conf_path" );
run_cmd($plugin, "$searchd_path --config $conf_path");
}
View
70 plugins/SphinxSearch/php/function.mtsphinxtagpool.php
@@ -0,0 +1,70 @@
+<?php
+# Movable Type (r) (C) 2001-2009 Six Apart, Ltd. All Rights Reserved.
+# This code cannot be redistributed without permission from www.sixapart.com.
+# For more information, consult your Movable Type license.
+#
+# $Id$
+
+function smarty_function_mtsphinxtagpool($args, &$ctx) {
+
+ if( !empty($args['div']) )
+ $div = $args['div'];
+ else
+ $div = 'tagpool';
+
+ $cats = $args['category'];
+
+ if( !empty($args['template']) )
+ $tmpl = $args['template'];
+ else
+ $tmpl = 'tagcloud';
+
+ if( !empty($args['searchall']) )
+ $searchall = $args['searchall'];
+ else
+ $searchall = '1';
+
+ if( !empty($args['include_blogs']) )
+ $blogs = $args['include_blogs'];
+ else if( !empty($args['blog_ids']) )
+ $blogs = $args['blog_ids'];
+ else if( !empty($args['blog_id']) )
+ $blogs = $args['blog_id'];
+ else
+ $blogs = '';
+
+ if( !empty($args['jquery']) )
+ $load_jquery = $args['jquery'];
+ else
+ $load_jquery = '0';
+
+ if($load_jquery != '0')
+ $load_jquery = '<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>';
+
+ if($load_jquery == '0')
+ $load_jquery = '';
+
+ global $mt;
+ $script = $ctx->mt->config('SearchScript');
+
+ $cgi_path = $mt->config('CGIPath')."/$script";
+
+ $html = <<<HTML
+
+ $load_jquery
+ <div id="tagpool">
+ <div id="waiting">...</div>
+ </div>
+ <script type="text/javascript">
+ \$(document).ready(function(){
+ \$.get("$cgi_path", { IncludeBlogs: "$blogs", index: "tag", Template: "$tmpl", searchall: "$searchall", category: "$cats", sort_by: "entry_count" },
+ function(data){
+ // alert("Data Loaded: " + data);
+ \$("#$div").html(data);
+ });
+ });
+ </script>
+HTML;
+
+ return $html;
+}
View
10 plugins/SphinxSearch/t/01-indexes.t
@@ -36,13 +36,13 @@ is( scalar SphinxSearch::Index->which_indexes,
check_indexes(
{ Indexer => 'all' },
- [qw( entry_index entry_delta_index comment_index comment_delta_index )],
+ [qw( entry_index entry_delta_index comment_index comment_delta_index tag_index )],
"All indexer indexes"
);
check_indexes(
{ Indexer => 'main' },
- [qw( comment_index entry_index )],
+ [qw( comment_index entry_index tag_index )],
"Main indexer indexes"
);
@@ -80,6 +80,12 @@ check_indexes(
"Entry and comment source indexes"
);
+check_indexes(
+ { Source => ['tag'] },
+ [qw( tag_index )],
+ "Tag array source indexes"
+);
+
require MT;
MT->config->UseSphinxDistributedIndexes(1);
View
6 plugins/SphinxSearch/t/tasks.t
@@ -46,7 +46,7 @@ SKIP:
$plugin->start_indexer;
my @indexes = grep { /_index/ } split (/\s+/, join (' ' , @args));
- cmp_bag (\@indexes, [qw( entry_index comment_index )], "Entry and comment indexes present for unspecified indexer");
+ cmp_bag (\@indexes, [qw( entry_index comment_index tag_index )], "Entry, comment and tag indexes present for unspecified indexer");
$plugin->start_indexer ('delta');
@indexes = grep { /_index/ } split (/\s+/, join (' ' , @args));
@@ -54,7 +54,7 @@ SKIP:
$plugin->start_indexer ('all');
@indexes = grep { /_index/ } split (/\s+/, join (' ' , @args));
- cmp_bag (\@indexes, [ qw( entry_index entry_delta_index comment_index comment_delta_index )], "All indexes being indexed");
+ cmp_bag (\@indexes, [ qw( entry_index entry_delta_index comment_index comment_delta_index tag_index )], "All indexes being indexed");
ok (!$plugin->start_indexer ('gobbledeegook'), "start_indexer with garbage argument should return false");
@@ -65,7 +65,7 @@ SKIP:
lives_ok { $plugin->sphinx_indexer_task ('main') } 'sphinx_indexer_task should live if launching succeeds';
@indexes = grep { /_index/ } split (/\s+/, join (' ' , @args));
- cmp_bag (\@indexes, [qw( entry_index comment_index )], "Entry and comment indexes present for sphinx_indexer_task");
+ cmp_bag (\@indexes, [qw( entry_index comment_index tag_index )], "Entry, comment and tag indexes present for sphinx_indexer_task");
$fail = 0;
throws_ok { $plugin->sphinx_indexer_task ('delta') } qr/Error starting [^:]*: Testing!/;
View
46 plugins/SphinxSearch/templates/tagcloud.tmpl
@@ -0,0 +1,46 @@
+
+<style>
+
+ .sidebar-tags { margin: 0px; }
+ .sidebar-tags .tag {
+ display: block;
+ float: left;
+ }
+ .sidebar-tags ul { list-style-type: disc; }
+ .sidebar-tags .tag a {
+ background-color: white;
+ border-color: #ABA9A9;
+ border-style: solid;
+ border-width: 1px;
+ color: #2D2D2D;
+ float: left;
+ font-size: x-small;
+ font-weight: bold;
+ list-style-type: none;
+ margin-bottom: 2px;
+ margin-right: 2px;
+ padding: 5px;
+ text-transform: uppercase;
+ text-decoration: none;
+ }
+ .sidebar-tags .tag a:hover {
+ background-color: #CCDDEE;
+ color: #093D72;
+ outline: none;
+ text-decoration: none;
+ }
+</style>
+
+<ul class="sidebar-tags">
+ <MTSearchResults>
+ <li class="tag">
+ <a href="<mt:TagSearchLink>" title="<mt:TagName> (<mt:TagCount>)">
+ <mt:TagName>
+ </a>
+ </li>
+ </MTSearchResults>
+</ul>
+<br /><br /> <hr />
+
+<mt:NoSearchResults> No tags found... </mt:NoSearchResults>
+<mt:NoSearch> Tags not found... </mt:NoSearch>
View
155 plugins/SphinxSearch/templates/tagsearch.tmpl
@@ -0,0 +1,155 @@
+<mt:blogs include_blogs="all">
+ <mt:setvarblock name="options" append="1">
+ <option value="<mt:BlogId>"><mt:BlogName></option>
+ </mt:setvarblock>
+
+ <mt:setvarblock name="opt"><mt:BlogId></mt:setvarblock>
+ <mt:var name="allopts" function="push" value="$opt">
+</mt:blogs>
+
+<html>
+<head>
+ <title>Sphinx Tags Search :: Test page </title>
+ <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
+ <script>
+
+ $(document).ready(function() {
+ $('#searchtxt').attr("disabled", true);
+
+ $("#searchtxt").click(function() {
+
+ if($(this).attr("value") == "(specify a search term to find)" )
+ $(this).attr("value", "");
+ });
+ });
+ function setsearch(sel) {
+
+ if(sel.value == '1') {
+ $('#searchtxt').attr("disabled", true);
+ $("#searchtxt").attr("value", "(specify a search term to find)");
+ } else {
+ $('#searchtxt').removeAttr("disabled");
+ }
+ }
+ </script>
+</head>
+<body>
+ <h2>Sphinx Tags Search :: Test page</h2>
+ <mt:setvarblock name="searchscript"><mt:CGIPath><mt:SearchScript></mt:setvarblock>
+ <a href="<mt:var name='searchscript'>?IncludeBlogs=<mt:var name="allopts" glue=",">&index=tag&sort_by=entry_count&Template=tagsearch&search=shoe">
+ Simple Search Term Test</a> <br />
+ <a href="<mt:var name='searchscript'>?IncludeBlogs=<mt:var name="allopts" glue=",">&index=tag&sort_by=entry_count&Template=tagsearch&search=&category=travel">
+ Search Term + Category Filter Test</a> <br />
+
+ <a href="<mt:var name='searchscript'>?IncludeBlogs=<mt:var name="allopts" glue=",">&index=tag&sort_by=entry_count&Template=tagsearch&searchall=1&category=design">
+ Search-ALL + Category Filter Test</a> <br />
+
+ <hr />
+
+ <h3>Search Parameters sent:</h3>
+ MatchMode: <mt:SearchMatchMode> <br />
+ SearchSortMode: <mt:SearchSortMode> <br />
+ SearchAllResult: <mt:SearchAllResult> <br />
+ SearchResultsPage: <mt:SearchResultsPage> <br />
+ SearchFilterValue: <mt:SearchFilterValue name="category"> <br />
+ SearchParameters: <mt:SearchParameters> <br />
+ SearchTotalPages: <mt:SearchTotalPages> <br />
+ <hr />
+
+ <form method="GET" action="<$MTCGIPath$><$MTSearchScript$>">
+
+ <h3>Search within Blogs</h3>
+ <p>
+ <select name="IncludeBlogs" multiple="1">
+ <option value="<mt:var name="allopts" glue=",">">All</option>
+ <mt:var name="options">
+ </select>
+ </p>
+
+ <!-- Important Hidden Params -->
+ <input type="hidden" name="index" value="tag" />
+ <input type="hidden" name="Template" value="tagsearch" />
+ <input type="hidden" name="sort_by" value="entry_count" />
+
+ <h3>Search terms</h3>
+ <p>
+ <input type="radio" name="searchall" value="1" onchange="setsearch(this)" checked />Search all tags<br />
+ <input type="radio" name="searchall" value="0" onchange="setsearch(this)" />Search specific tags
+ <input type="text" name="search" id="searchtxt" size="50" value="(specify a search term to find)">
+ </p>
+
+ <h3>Search within categories</h3>
+ <p>
+ <mt:setvar name="options" value=""></mt:setvar>
+ <mt:setvar name="allopts" value=""></mt:setvar>
+ <mt:categories >
+ <mt:setvarblock name="options" append="1">
+ <option value="<mt:CategoryBaseName>"><mt:CategoryLabel></option>
+ </mt:setvarblock>
+
+ <mt:setvarblock name="opt"><mt:CategoryLabel></mt:setvarblock>
+ <mt:var name="allopts" function="push" value="$opt">
+ </mt:categories>
+
+ <select name="category">
+ <option value="<mt:var name="allopts" glue=",">">All</option>
+ <mt:var name="options">
+ </select>
+ </p>
+
+ <input type="submit" value="<MT_TRANS phrase="Find tags">" />
+ </form>
+
+ <hr />
+
+ <h2>Search Results:</h2>
+ <style>
+ body { font-size: 12px; }
+ ul { list-style-type: disc; }
+ .sidebar-tags { margin: 0px; }
+ .sidebar-tags .tag {
+ display: block;
+ float: left;
+ }
+ .sidebar-tags .tag a {
+ background-color: white;
+ border-color: #ABA9A9;
+ border-style: solid;
+ border-width: 1px;
+ color: #2D2D2D;
+ float: left;
+ font-size: x-small;
+ font-weight: bold;
+ list-style-type: none;
+ margin-bottom: 2px;
+ margin-right: 2px;
+ padding: 5px;
+ text-transform: uppercase;
+ text-decoration: none;
+ }
+ .sidebar-tags .tag a:hover {
+ background-color: #CCDDEE;
+ color: #093D72;
+ outline: none;
+ text-decoration: none;
+ }
+ </style>
+ <ul class="sidebar-tags">
+ <MTSearchResults>
+ <li class="tag">
+ <a href="<mt:TagSearchLink>" title="<mt:TagName> (<mt:TagCount>)">
+ <mt:TagName>
+ </a>
+ </li>
+ </MTSearchResults>
+ </ul>
+
+ <br /><br />
+ <hr />
+
+ <mt:NoSearchResults> No results... </mt:NoSearchResults>
+
+ <mt:NoSearch> No search was executed... </mt:NoSearch>
+
+</body>
+</html>
View
2  plugins/SphinxSearch/tmpl/sphinx.conf.tmpl
@@ -285,7 +285,7 @@ indexer
searchd
{
# port on which search daemon will listen
- port = <TMPL_VAR NAME=SEARCHD_PORT>
+ listen = <TMPL_VAR NAME=SEARCHD_PORT>
# log file
View
2  plugins/SphinxSearch/tmpl/sphinx.xpipe.conf.tmpl
@@ -219,7 +219,7 @@ indexer
searchd
{
# port on which search daemon will listen
- port = <TMPL_VAR NAME=SEARCHD_PORT>
+ listen = <TMPL_VAR NAME=SEARCHD_PORT>
# log file
View
2  plugins/SphinxSearch/tools/gen_xpipe_stream
@@ -10,7 +10,7 @@ use warnings;
my $verbose;
-my @SUPPORTED_CLASSES = qw( Blog Author Comment Entry );
+my @SUPPORTED_CLASSES = qw( Blog Author Comment Entry Tag );
my @SUPPORTED_INDICES = qw( main delta );
my $index_type;
Please sign in to comment.
Something went wrong with that request. Please try again.