Jump to:

1970 Posts in 1275 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Site Search Results Page - Some Issues...

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

Page: 1
Go to End
Author Topic: 2336 Views
  • HenryE
    Avatar
    Community Member
    6 Posts

    Site Search Results Page - Some Issues... Link to this post

    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

  • FnC/odontodactylus
    Avatar
    Community Member
    7 Posts

    Re: Site Search Results Page - Some Issues... Link to this post

    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.

  • HenryE
    Avatar
    Community Member
    6 Posts

    Re: Site Search Results Page - Some Issues... Link to this post

    Hi odontodactylus,

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

    /H.

  • Lucyjamm
    Avatar
    Community Member
    6 Posts

    Re: Site Search Results Page - Some Issues... Link to this post

    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!!!

    2336 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.