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

Forums / Developing with Sitefinity / View page description in searchresults

View page description in searchresults

10 posts, 1 answered
  1. Rick
    Rick avatar
    15 posts
    Registered:
    15 Aug 2011
    31 Jan 2012
    Link to this post
    Hello,

    I would like to display the description of the pages at the same place as where the summary is for news items. I removed the HighLighterResult since that also gave a lot of other things I don't need. Then I tried adding Eval("Description") but this isn't recognised and results in an error.  Is there any way to add the Description field of pages in stead of only the Summary in, for example, news items?

    Below is the code I am using at the moment.
    <ItemTemplate>
            <dt class="sfsearchResultTitle"><a runat="server" href='<%# Eval("Link")%>'><%# Eval("Title") %></a></dt
            <dd class="sfsearchResultSnippet"><%# Eval("Summary")%></dd>
            <dd class="sfsearchResultUrl"><a runat="server"  href='<%# Eval("Link")%>'><%# Eval("Link")%></a></dd>
        </ItemTemplate>


    Rick.
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    06 Dec 2016
    03 Feb 2012
    Link to this post
    Hello Rick,

    For our search indexing functionality we're using Lucene. The search results that are displayed when you perform search are of type IDocument and are stored in an IResultSet, in other words these are not the actual pages. However each of these documents contains a property ContentType which can be used to determine what is the actual object type it represents. Once you determine if the object is of the desired type (PageNode in your case) you can get the OriginalItemId property of the document, which represents the actual item ID. usingt he corresponding manager you can get the object ad access any of its fields so you can display the information on the template. What you can do is create an external template based on the original one, and subscribe to the DataBound event of the repeater control where you'll be checking each item. Here's an example how you can perform this check for products inside the search result:'

    var type = myitem.GetValue("ContentType");
                    //You need to check for the type of the item you have gotten in your search results
                    //here we're checking if the item is an eCommerce product:
                     if (TypeResolutionService.ResolveType(type) == typeof(Product))
                     {
                         var ID = new Guid(myitem.GetValue("OriginalItemId"));
                        //you can now get the item with its manager and access its properties,
                        //since you'll be working with an object of the correct type
                        //for example:
                         var manager = CatalogManager.GetManager();
                         var product = manager.GetProduct(ID);
                         var myOwner = product.Owner; //please none this is an ID of the user
                         var displayName = UserProfilesHelper.GetUserDisplayName(myOwner);
                         //get the FirstName and LastName from the string
                         var FirstName = displayName.Split(' ').First();
                         var LastName = displayName.Split(' ').Last();
                     }


    All the best,
    Boyan Barnev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Robert
    Robert avatar
    7 posts
    Registered:
    03 Feb 2012
    28 Feb 2012
    Link to this post
    Your solution is geared towards an ASP.NET developer, but how can an ordinary web designer or content user implement this who lacks understanding of asp.net?

    Is there an easier way to do this? just like settings properties in the search module or backend administration?

    If coding is the only solution, can you please kindly include the complete page and code behind solution to do this, in a way like a non asp.net developer can follow?
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    06 Dec 2016
    01 Mar 2012
    Link to this post
    Hi Robert,

    Thanks for pointing this out, please find attached a customized SearchResults template that you can add to your project, build it and then go to the page where your SearchResults widget is placed, edit the widget and in the Advanced properties find the LayoutTemplatePath property and enter there the application relative path to the customized template. Save the changes and publish the page - the SearchResults widget will now use your custom template instead of the default one, and it will have the desired logic implemented - display the Page Description in the SearchResults.

    All the best,
    Boyan Barnev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. Gregg
    Gregg avatar
    7 posts
    Registered:
    02 Jun 2008
    09 Nov 2012 in reply to Boyan Barnev
    Link to this post
    Hi Boyan-

    I tried this and I get some weird results. When I edit the LayoutTemplatePath Property in the Advanced Properties and hit 'Save', the value is never saved. When I go back into the form the value always reverts back to ~/SFRes/Telerik.Sitefinity.Resources.Templates.PublicControls.SearchResults.ascx.

    Is there another property that has to be changed? Do I need to register the new Search widget somewhere?

    Warm Regards,

    Gregg Crystal
  6. Patrick Dunn
    Patrick Dunn avatar
    237 posts
    Registered:
    03 Nov 2014
    14 Nov 2012
    Link to this post
    Hi Gregg,

     Where in the file structure are you storing your custom templates and what is the URL you are using to reference them? Also make sure you don't have a template selected from the basic view mode as well.

    Greetings,
    Patrick Dunn
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. Ricardo
    Ricardo avatar
    29 posts
    Registered:
    06 Nov 2012
    02 May 2013
    Link to this post
    Thanks for the code, but I am also having the same issue. I am pretty sure there is no template selected and just referencing to ~/Modules/Folder/Control.ascx but it keeps replacing it for some reason. Any other way of forcing this?

    Many thanks,

    Ricardo
  8. Dev
    Dev avatar
    18 posts
    Registered:
    18 Jan 2013
    06 May 2013
    Link to this post
    Same problem here, it reverts back all the time when I hit save.
  9. Gregg
    Gregg avatar
    7 posts
    Registered:
    02 Jun 2008
    06 May 2013
    Link to this post
    Hello-
    If the LayoutTemplatePath property is not saving, then you have an error in your ascx or cs file. Sitefinity is just quietly failing. My issue turned out to be I was referencing the wrong assembly in my ascx file, as the assemblies have changed between v4 and v5. Some of the examples in this forum are the 'old' way.

    In my code, which now works, I had to change the register tags to this:

    <%@ 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" %>

    Hope this helps!
    -Gregg
    Answered
  10. Dev
    Dev avatar
    18 posts
    Registered:
    18 Jan 2013
    06 May 2013
    Link to this post
    Gregg,

    Thanks for the reply. Your input gave me a lead to find the problem. Yes, there is something wrong in the ascx file. In my case, I am missing the sitefinity pager, top and bottom search box. Its actually strange, I have nt added them because, I dont need them, but sitefinity is expecting them in the control, so i added them and hidden them. Thanks for the reply though
10 posts, 1 answered