Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • curtismccaw 29 posts 89 karma points
    Jun 06, 2023 @ 15:28
    curtismccaw
    0

    @result.Content.Url() returns #

    Hi,

    Im using a standard page search but my search results are returning #. Looks like it can't get the URL for the node. The search does return the page ID and a property from the page okay.

          @if (!string.IsNullOrWhiteSpace(searchQuery))
                    {
                        var results = publishedContentQuery.Search(searchQuery);
                        long resultCount = results != null && results.Any() ? results.Count() : 0;
                        @Html.Raw(string.Format(Umbraco.GetDictionaryValue("Search.Results"), resultCount, searchQuery))
                        if
                        (resultCount > 0)
                        {
                            <div>
                                <p class="text-lg">Your search for <span
                                class="font-normal text-bright-blue text-xl uppercase text-left tracking-wide">@searchQuery</span>
                                    returned <span
                                class="font-normal text-bright-blue text-xl uppercase text-left tracking-wide">@results.Count()
                                    </span>results.</p>
                            </div>
    
                            foreach (var result in results)
                            {
                                <li class="bg-[#F0F7FF] hover:bg-[#007AFF]" data-aos="fade-up">
    
    
                                    <a href="@result.Content.Url()">
                                        <div class="group flex flex-col md:flex-row p-10 h-full text-dark-blue hover:text-white items-center justify-between">
                                            <div class="block md:flex justify-between items-center max-w-full w-full">
                                                <div class="capitalize">
                                                    <h3 class="mr-5 block">
                                                        page iD: @result.Content.Id; <br><br>
                                                        @(result.Content.HasProperty("title") && result.Content.HasValue("title") &&
                                            !string.IsNullOrWhiteSpace(result.Content.Value<string>("title")) ?
                                            result.Content.Value("title") : result.Content.Name)
                                                    </h3>
                                                     @if (result.Content.HasValue("pageExcerpt"))
                                                    {
                                                        <p class="mt-3 mb-0 normal-case">@Html.Truncate(result.Content.Value<string>("pageExcerpt"), 200)</p>
                                                    }
                                                </div>
                                            </div>
    
                                        </div>
                                    </a>
                                </li>
                            }
    

    Any ideas as to why this might be?

  • Jane Carol 22 posts 92 karma points
    Feb 29, 2024 @ 12:46
    Jane Carol
    0

    Did u find an answer for this?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies