Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Site Search Results Page - Some Issues...


Go to End


4 Posts   3403 Views

Avatar
HenryE

Community Member, 6 Posts

7 April 2009 at 9:03pm

Edited: 07/04/2009 9:03pm

I recently followed some of the examples to fine tune the search results page. I should mention that I am much more of a designer than a coder.

Firstly, I was wondering if anyone out there knows how to tweak the code, to add a style to every situation in the results of the word that has been searched for. For example when you search for a word in google, in the results that are returned the word is styled in bold. Another example is in these forum searches, where the words appear highlighted. - I think this would add a lot to the search facility.

I also have another problem where for some reason line breaks are being inserted into some of my resulting paragraphs, but not ones that come from my blog pages. - I can not figure out what is causing this.

Also, if images or flash elements are at the top of the pages returned, fragments of these elements are appearing in the search results, and it would be great if there was an easy way to omit them, but I'm not sure how.

The code I am using for the Page_results.ss file is as follows:

<div class="typography">
	<% if Results %>
	    <ul id="SearchResults">
	      <% control Results %>
	        <li>     
			  <% if Content %>
	          	$Content.FirstParagraph(html)
			  <% end_if %>
	          <a class="readMoreLink" href="$Link" title="Read more about "{$Title}"">Read more about "{$Title}"...</a>
	        </li>
	      <% end_control %>
	    </ul>
	  <% else %>
	    <p>Sorry, your search query did not return any results.</p>
	  <% end_if %>

	  <% if Results.MoreThanOnePage %>
	    <div id="PageNumbers">
	      <% if Results.NotLastPage %>
	        <a class="next" href="$Results.NextLink" title="View the next page">Next</a>
	      <% end_if %>
	      <% if Results.NotFirstPage %>
	        <a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
	      <% end_if %>
	      <span>
	        <% control Results.SummaryPagination(5) %>
	          <% if CurrentBool %>
	            $PageNum
	          <% else %>
	            <a href="$Link" title="View page number $PageNum">$PageNum</a>
	          <% end_if %>
	        <% end_control %>
	      </span>
      
	    </div>
	 <% end_if %>
</div>

Anyway, if anyone can help or point me in the right direction it would be much appreciated.
http://www.henryegloff.com.au

Avatar
Form & Code

Community Member, 7 Posts

3 October 2009 at 7:17pm

About your linebreak problem: You might want to add

#SearchResults p {
padding:0;
margin:0;
}

#SearchResults li br {
display:none;
}

to your css. That display:none will get rid of the linebreak, though it looks a little ugly as no space is inserted.

Avatar
HenryE

Community Member, 6 Posts

3 October 2009 at 8:30pm

Hi odontodactylus,

Thanks heaps for the tip. - I'll check it out.

/H.

Avatar
Lucyjamm

Community Member, 6 Posts

21 January 2010 at 4:44am

Thank you, that css tip worked for me, has gotten rid of huge gaps between lines - very glad to have finally fixed that as it was getting on my nerves somewhat!!!