This mod allows hardcoded searches like:
http://www.yoursite.com/index.php?m=search&issearch=1&gender1=2
to be RSSd, by adding &rss to the query string.
eg:
http://www.yoursite.com/index.php?m=search&issearch=1&gender1=2&rss
So in this example , with the above link, people will have access to an RSS feed for the last X females who joined your dating site, assuming:
gender1 value of 2 is a female
X being the number of results shown per search results page
It took me 10mins to write this mod, so please backup your code, and if you see any potential problems, or ways it could be done better, or bugs please let us know.
In my very limited testing with my site (which is not open yet) it seems to work, so fingers crossed.
Also this is tested with vld 2.5.3
In .htaccess:
Find
RewriteRule ^search/([0-9a-zA-Z]+)/?$ index.php?m=search&s=$1
Replace with:
RewriteRule ^search/([0-9a-zA-Z]+)/?$ index.php?m=search&s=$1&%{QUERY_STRING}
In lib.search.php:
Find the line starting with:
redirect(VIR_PATH . ($PREFS->conf['fancy_urls'] ? "search/$search_hash/
IMPORTANT: ONLY THE ONE WITHIN THE FUNCTION show_search($advanced)
Replace it with:
//MOD START
$rss_string = "";
$rss_fancy_string = "";
if ( isset($_GET['rss']) ) {
$rss_string = "&rss";
$rss_fancy_string = "?rss";
}
redirect(VIR_PATH . ($PREFS->conf['fancy_urls'] ? "search/$search_hash/$rss_fancy_string" : "index.php?m=search&s=$search_hash$rss_string"));
//MOD END
The final mods are all within the function show_search_results($hash, $page).
Find:
$TEMPLATE->set_template("search_results.tpl");
Replace it with:
//MOD START
if ( !isset($_GET['rss']) ) {
$TEMPLATE->set_template("search_results.tpl");
} else {
$search_orderby = 'joindate';
}
//MOD END
Find:
$search_orderby = $obj->query_orderby ? $obj->query_orderby : 'lastvisit';
Replace it with:
if ( !isset($_GET['rss']) ) $search_orderby = $obj->query_orderby ? $obj->query_orderby : 'lastvisit'; //MOD
Find:
$directionbox['asc'] = $LANG['search']['ascending'];
THEN PLACE AFTER (NOT REPLACE):
//MOD START
if ( isset($_GET['rss']) ) {
//------------------------------------------------
// Parse feed header
//------------------------------------------------
$output =
'<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>'.htmlentities2utf8($PREFS->conf['app_title'] . ' | ' . $LANG['search']['app_search_rss']).'</title>
<link></link>
<description>'.htmlentities2utf8($PREFS->conf['app_description']).'</description>';
//------------------------------------------------
// Parse feed items
//------------------------------------------------
$TEMPLATE->assign('search_profiles', $profile_obj);
$output .= $TEMPLATE->result('search_rss.tpl');
$output .= '</channel></rss>';
header('Content-Type: application/rss+xml; charset=utf-8');
echo $output;
exit();
}
//MOD END
If anybody adds this their live site I would love to know, and see it in action with a more complete member base than my 10 test members.
A mod like this will hopefully keep your members coming back.






Comments
idealists
I still like my mod - the URL is more friendly and doesn't need admin to create saved searches!
radioact
This will work unless I delete it, but I won't :)
idealists
The point of this is so you could have a hard-coded link, visible to all members, saying something like:
Latest female members RSS feed.
eg:
<a href="http://www.yoursite.com/index.php?m=search&issearch=1&gender1=2&rss">Latest female members -RSS feed.</a>
Maybe next to a hard-code search on female members:
<a href="http://www.yoursite.com/index.php?m=search&issearch=1&gender1=2">All Female members</a>
radioact
idealists
The resulting line after the mod should look like:
RewriteRule ^search/([0-9a-zA-Z]+)/?$ index.php?m=search&s=$1&%{QUERY_STRING} [L]
Log in to leave a comment