+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Customized search results

Customized search results

11 posts, 0 answered
  1. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    03 Feb
    Link to this post

    I have a page with a list of questions and answers in an expandable list. 

    Also on this page I have a search box, when I search the list I get the results with links to separate pages. I want to display the result in a expandable list with only the title of the list item showing.

    I've made a new template for the search result and tried to copy over some code from the template for the expandable list but it only shows the title with nothing happening when you click it.

     

    Anyone have any suggestions?

    Best regards

     

    The template:

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Sitefinity.Search.Impl" Namespace="Telerik.Sitefinity.Services.Search.Web.UI.Public" TagPrefix="sfSearch" %>
     
    <sfSearch:SearchBox ID="topSearchBox" runat="server" />
     
    <sitefinity:SitefinityLabel id="resultsStats" runat="server" WrapperTagName="p" CssClass="sfsearchResultStatistics" Text="<%$Resources:SearchResources, SearchResultsStatusMessage %>" />
     
    <asp:Repeater ID="resultsList" runat="server">
        <HeaderTemplate>
            <dl class="sfsearchResultsWrp sfsearchReultTitleSnippetUrl">
        </HeaderTemplate>    
        <ItemTemplate>       
          <h2 class="sflistTitle">
                    <asp:Literal runat="server" Text='<%# Eval("Title") %>' />
                </h2>
                <telerik:RadListView ID="listItemsControl" runat="server"
                        ItemPlaceholderID="ItemsContainer"
                        EnableEmbeddedSkins="false"
                        EnableEmbeddedBaseStylesheet="false">
                    <LayoutTemplate>
                        <ul class="sflistList">
                            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
                        </ul>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <li class="sflistListItem">
                            <h3 class="sflistItemTitle">
                                <asp:LinkButton runat="server" ID="listItemToggleLnk" class="sflistItemToggleLnk" Text='<%# Eval("Title") %>' OnClientClick="return false;" />
                            </h3>
                            <div runat="server" ID="listItemContent" class="sflistItemContent" style="display: none;">
                                <asp:Literal runat="server" Text='<%# Eval("Content") %>' />
                            </div>                       
                        </li>
                    </ItemTemplate>
                </telerik:RadListView>
        </ItemTemplate>
        <FooterTemplate>
            </dl>
        </FooterTemplate>
    </asp:Repeater>
    <sitefinity:Pager ID="pager" runat="server" />
    <sfSearch:SearchBox ID="bottomSearchBox" runat="server" />

     

     

  2. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    05 Feb
    Link to this post

    Anyone have any suggestions?

    Since the answers are all rather short I was thinking of showing the content in full always. I will try that now but I rather prefer the expandable list if possible. 

     

  3. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    27 Sep 2016
    08 Feb
    Link to this post
    Hello Andreas,

    You can try the following approach, changing the search results template, for example like:
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Sitefinity.Search.Impl" Namespace="Telerik.Sitefinity.Services.Search.Web.UI.Public" TagPrefix="sfSearch" %>
     
    <sfSearch:SearchBox ID="topSearchBox" runat="server" />
     
    <sitefinity:SitefinityLabel id="resultsStats" runat="server" WrapperTagName="p" CssClass="sfsearchResultStatistics" Text="<%$Resources:SearchResources, SearchResultsStatusMessage %>" />
     
    <asp:Repeater ID="resultsList" runat="server">
        <HeaderTemplate>
            <dl class="sfsearchResultsWrp sfsearchReultTitleSnippetUrl">
        </HeaderTemplate>
        <ItemTemplate>
                        <li class="sflistListItem sflistitem" data-sf-provider='Default'  data-sf-id='<%# Eval("Id")%>' data-sf-type="Telerik.Sitefinity.Lists.Model.ListItem">
                            <h3 class="sflistItemTitle sftitle">
                                <asp:LinkButton runat="server" ID="listItemToggleLnk" class="sflistItemToggleLnk" Text='<%# Eval("Title") %>' OnClientClick="return false;" data-sf-field="Title" data-sf-ftype="ShortText"/>
                            </h3>
                            <div runat="server" ID="listItemContent" class="sflistItemContent sfcontent" style="display: none;" data-sf-field="Content" data-sf-ftype="LongText">
                                <asp:Literal runat="server" Text='<%# Eval("Content") %>' />
                            </div>
                        </li>     
           
     
        </ItemTemplate>
        <FooterTemplate>
            </dl>
        </FooterTemplate>
    </asp:Repeater>
    <sitefinity:Pager ID="pager" runat="server" />
    <sfSearch:SearchBox ID="bottomSearchBox" runat="server" />
       
    <script language="javascript" type="text/javascript">
     $(".sflistItemTitle.sftitle").click(function() {
      $(this).next().toggle("slow", function() {
        // ...
      });
    });
    </script>

    I hope this helps.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  4. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    08 Feb
    Link to this post

    Awesome. It works as expected. Thanks. 

    Another problem appeared though. I have a CustomSearchResult set in the ViewMap which is used everywhere but I want the regular search results on the site to have a different template. 

    I have tried deleting the viewmap setting and created 2 templates within the search result (see screenshot). But when I do the standard sitefinity search result design is used (not the one i used In the ViewMap)

    Is their something I need to set in the advanced tab?

  5. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    27 Sep 2016
    09 Feb
    Link to this post
    Hi Andreas,

    Generally speaking, when you have ViewMaped template it will be used wherever the type is called. Once you delete the ViewMap you need to restart the application in order to stop using that template.

    Regarding the search results - the template selected in the search results widget dropped on a page will be used. In case you need different templates for Lists search and other search, you need to have different pages where the Search box is pointing to (where the respective Search results widget is placed).
    For example: Standard search box points to "Search results" page but Lists search box points to "List Search results" page, where the respective template is selected (as per your screenshot).

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  6. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    11 Feb
    Link to this post

    Thanks for the reply but I think you misunderstood.

    The search result on the List where I have the expandable template selected shows the standard/default searchresult template, Not my old custom template.

    Is this a behavior for it when the template you have selected does not work?

    Best regards

  7. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    11 Feb
    Link to this post

    This is very weird.

    On my standard site search my custom search template worked (the text is in swedish)

    Just to test, I changed to the expandable template. Then the results shows up in the default layout (english)

    I change back to the regular custom template again, but the results stays in default layout....

    what :S

  8. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    27 Sep 2016
    15 Feb
    Link to this post
    Hi Andreas,

    Changing between the templates in the search results widget seems works fine.

    Can you please provide a video demonstration of the steps performed? Alternatively, in order to inspect your project more detailed you can open a support ticket. Once you have the solution you can share it with the community.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  9. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    16 Feb in reply to Svetoslav Manchev
    Link to this post

    Created new page and added the search controls.

    Chose the titlesonly -> Shows only titles

    Chose the standard -> Shows standard

    Chose the titlesonly -> Shows only titles  (so changing seems to work)

    Chose the expandable (with your supplied code)-> Shows standard

     Chose the titlesonly -> Still shows standard

    screencast

    Do I have to do something more with the created templates? (I created them from the select template window)

  10. Andreas
    Andreas avatar
    17 posts
    Registered:
    03 May 2013
    25 Feb
    Link to this post
    Anyone?
  11. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    27 Sep 2016
    29 Feb
    Link to this post
    Hello Andreas,

    Thank you for the detailed description and the video demonstration.

    I have tested the same scenario and it works fine, and the templates are changing. I can recommend you to open a support ticket in order to inspect your project more detailed.

    You can look for any errors when using your template (~/App_Data/Sitefinity/Log). Remove the files there in advance, reproduce the issue and check for any files generated. You can check also for any browser errors.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
11 posts, 0 answered