Customizing tag listing - how?

Topics: Customizing Orchard
Oct 10, 2014 at 6:09 AM
Trying to find it with shape tracing but it ends up showing me zone-content
What cshtml do I have to create in order to override the tag listing that is shown for example at
http://localhost/Tags/infrastructure i.e. the items under /Tags/xxxx?
Oct 13, 2014 at 3:34 AM
Hi!
I think the only way to override this shape is to override the "Orchard.Tags/Home/Search.cshtml" in your Theme.
Oct 13, 2014 at 1:56 PM
Can you elaborate? What is the name of the .cshtml file I need to create in my themes view folder?
Oct 13, 2014 at 2:01 PM
Found it.

Runs down to:

https://orchard.codeplex.com/workitem/17847

which I reached via

https://orchard.codeplex.com/discussions/257933

Once I knew it is the search view, things started falling into place.

Excelt I still wonder where the list is being rendered. Search.chhtml refers to another listing. And the shape browser looks empty.
Oct 13, 2014 at 3:39 PM
Edited Oct 13, 2014 at 3:41 PM
Hi!

Search.cshmtl calls Display with an List of ContentItems as parameter. So each content item will be rendered as summary shape for that contentitem. If you want to change the render behavior you have to take care of the rendering of this list of contentitems in search.cshtml.

I did this in the Search Index.cshtml and my code is:
@model Orchard.Search.ViewModels.SearchViewModel
@using Orchard.ContentManagement
@using Orchard.Mvc.Html;
@{
    Style.Require("Search");

    IEnumerable<object> searchResults = Model.ContentItems;
    Model.ContentItems.Classes.Add("content-items");
    Model.ContentItems.Classes.Add("search-results");
    int i = 1;
    }
    <h1>@Html.TitleForPage(T("Search").Text)</h1>

    @if (HasText(Model.Query)) {
        if (!searchResults.Any()) {
            <p class="search-summary">@T.Plural("There is <em>one</em> result", "<em>zero</em> results", searchResults.Count())</p>
        } else {
            <p class="search-summary">@T.Plural("There is <em>one</em> result", "<em>{1} - {2}</em> of <em>{0}</em> results", Model.TotalItemCount, Model.StartPosition, Model.EndPosition)</p>
        }
    }
    @if (searchResults != null && searchResults.Any())
    {
        <table id="searchtable" class="table">
            @foreach (dynamic searchResult in searchResults)
            {
                i++;
                var cl = "odd";
                if (i % 2 == 0) {cl = "even";}
                <tr class="@cl">
                    <td>
                        @{
                            var url = Url.ItemDisplayUrl((IContent)searchResult.ContentItem);
                        }
                        <h4><a href="@url">@searchResult.ContentItem.TitlePart.Title</a></h4>
                    </td>
                    <td>
                        <span>@searchResult.ContentItem.ContentType.ToString()</span>
                    </td>
                </tr>
            }
        </table>
        @Display(Model.Pager)
    }


    <style type="text/css">
        ul {
            list-style: none;
        }
    </style>
In this case searchResults is my list of contentItems. I have to iterate throw them and because I know that every content item in my search index has a titlepart - I grep that and display only the title and the type of the contentitem.