Skip to content

Commit

Permalink
Incorrect title when searching
Browse files Browse the repository at this point in the history
Added some template logic to the Header and Master Search Results modules to detect searching in a global context and

* Set the 'system page' flag, to avoid hundreds of 'about me' boxes on the sidebar
* Set a blog_override value (to 1)

Header will detect this and set the relevant strings to blog #1s, instead of giving the values from the first search result. (The <title> is being manually set to "$name search results", which may eventually need to change. This does not apply for search results on single blogs; see the distinction between:

http://blogs.perl.org/mt/mt-search.fcgi?IncludeBlogs=100&limit=20&search=database
and
http://blogs.perl.org/mt/mt-search.fcgi?limit=20&search=database

This addresses github issue39
  • Loading branch information
snark authored and davorg committed May 3, 2010
1 parent 1f0dafb commit 88e06b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 deletions GLOBAL/modules/Header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@
<!-- Community Solution Blog variables -->
<!-- The below variables are used when there a blog is in context. -->
</mt:Ignore>
<mt:If var="blog_override">
<mt:MultiBlog include_blogs="1">
<mt:SetVarBlock name="blog_name"><$mt:BlogName encode_html="1"$></mt:SetVarBlock>
<mt:SetVarBlock name="blog_description"><$mt:BlogDescription$></mt:SetVarBlock>
<mt:SetVarBlock name="blog_url"><$mt:BlogURL$></mt:SetVarBlock>
<mt:unless name="title"><mt:SetVarBlock name="title"><mt:var name="blog_name"> search results</mt:SetVarBlock></mt:unless>
<mt:SetVarBlock name="profile_view_url"><$mt:CGIPath$><$mt:CommunityScript$>?__mode=view&amp;blog_id=<$mt:BlogID encode_html="1"$>&amp;id=</mt:SetVarBlock>
</mt:MultiBlog>
<mt:Else>
<mt:SetVarBlock name="blog_id"><$mt:BlogID$></mt:SetVarBlock>
<mt:SetVarBlock name="blog_name"><$mt:BlogName encode_html="1"$></mt:SetVarBlock>
<mt:SetVarBlock name="blog_description"><$mt:BlogDescription$></mt:SetVarBlock>
<mt:SetVarBlock name="blog_url"><$mt:BlogURL$></mt:SetVarBlock>
<mt:unless name="title"><mt:SetVarBlock name="title"><mt:var name="blog_name"> at blogs.perl.org</mt:SetVarBlock></mt:unless>
<mt:SetVarBlock name="profile_view_url"><$mt:CGIPath$><$mt:CommunityScript$>?__mode=view&amp;blog_id=<$mt:BlogID encode_html="1"$>&amp;id=</mt:SetVarBlock>
</mt:If>
<link href="<$mt:BlogURL$>styles/reset.css" rel="stylesheet" type="text/css" />
<link href="<$mt:BlogURL$>styles/base.css" rel="stylesheet" type="text/css" />
<link href="<$mt:StaticWebPath$>plugins/GCPrettify/prettify.css" rel="stylesheet" type="text/css" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="<$mt:Link template="feed_recent"$>" />
<link rel="alternate" type="application/atom+xml" title="Entries" href="<$mt:Link template="feed_recent"$>" />
<mt:If name='aggregator_main_index'>
<link rel="alternate" type="application/atom+xml" title="Comments" href="<$mt:Link template="Feed - Recent Comments"$>" />
</mt:If>
<link rel="start" href="<$mt:BlogURL$>" title="Home" />
<script type="text/javascript" src="<$mt:Link template="javascript"$>"></script>
<script type="text/javascript" src="<$mt:StaticWebPath$>plugins/GCPrettify/prettify.js"></script>
Expand Down Expand Up @@ -68,4 +81,5 @@
<div id="content-inner" class="pkg">
<div id="content-main">

<mt:If name='template_debug' ne='0'><!-- ######### END OUTPUT: Global Template Module - Header ######### --></mt:If>
<mt:If name='template_debug' ne='0'><!-- ######### END OUTPUT: Global Template Module - Header ######### --></mt:If>

9 changes: 8 additions & 1 deletion GLOBAL/modules/Master_Search_Results.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<mt:If name='template_debug' ne='0'><!-- ######### BEGIN OUTPUT: Search_Results ######### --></mt:If>

<mt:Ignore><!--
If we're searching multiple blogs, let's force the results page into
'aggregator mode' to avoid picking up the title from the first match.
Additionally, we'll set $blog_override to force Header to use blog #1's
title and tagline.
--></mt:ignore>
<mt:If tag='searchincludeblogs' like=','><$mt:Var name='system_page' value='1'$><mt:Var name="blog_override" value="1"></mt:If>
<$mt:Include module="Header"$>

<mt:Ignore><!--
Expand Down Expand Up @@ -83,3 +89,4 @@ var timer = window.setTimeout("getResults(" + <$mt:CurrentPage$> + ")", 1*1000);
</mt:IfMoreResults>

<$mt:Include module="Footer"$>

0 comments on commit 88e06b8

Please sign in to comment.