Copied to clipboard

Flag this post as spam?

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


  • Tom Cowling 144 posts 342 karma points
    Jun 08, 2015 @ 15:16
    Tom Cowling
    0

    No html tags

    Hey,

    I'm just putting the finishing touches to a search results page using the brilliantly simple package:

    https://our.umbraco.org/projects/website-utilities/simplistic-search

    I've tweaked the C# code to extend the description of a page so it shows a bit more text, but the text it displays is from a rich text editor and so the search results are showing the html that goes in this editor. I'm struggling a bit with the syntax for it and wondered if anyone could help?

    var displayPreamble = Model.MacroParameters["displayPreamble"].ToString();

    I'm guessing I need a StripHtml parameter in there? Or maybe something else.

     

    Thanks,

    Tom

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jun 08, 2015 @ 15:20
    Dennis Aaen
    0

    Hi Tom.

    Try to see this documentation. https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#StripHtml(stringhtml)

    I think that you should be able to do something like this

    @Umbraco.StripHtml(displayPreamble)
    

    Hope this helps,

    /Dennis

  • Tom Cowling 144 posts 342 karma points
    Jun 08, 2015 @ 15:42
    Tom Cowling
    0

    Hi Dennis,

    I don't thik I can use that. There's some funky stuff going on where values are passed from a macro partial to some CS and then to a partial stored in the views folder (I think that's be the correct order) and I'm struggling slightly with how it all fits together. I figured if I could make the data in the variable the stripped html first, then it would get passed through whatever happens as the process goes on.

    Maybe it would make a little more sense if I posted a stripped down version below? I've taken out all the other variables and macro parameters to keep it shorter.

    If your method would still work - could you point me in the right direction please?

    Thanks a lot!

    Tom

     

    Macro Partial:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        var displayPreamble = Model.MacroParameters["displayPreamble"].ToString();
    }



    @Html.Action("Search", "Simplistic", new
                                             {
                                                 displayPreamble
                                             })

    Partial:

    @using Simplistic
    @model Simplistic.SearchResultView
    @{
        IEnumerable<SearchResultItem> searchResults = Model.SearchResults.OrderBy(p => p.Node.Level).ThenBy(p => p.Node.SortOrder);
        if (Model.SortByRelevance)
        {
            searchResults = searchResults.OrderByDescending(p => p.HitCount);
        }
    }

    <strong>@(Model.SearchResults.Count)@Model.PresentationLabel '@Model.Term'</strong>

        @foreach (var node in searchResults)
        {
                <p>@(node.Description ?? "")</p>
        }
Please Sign in or register to post replies

Write your reply to:

Draft