Accessing ContainerWidget Properties

Topics: Troubleshooting
Aug 2, 2012 at 9:35 PM
Edited Aug 2, 2012 at 9:36 PM

I wrote an alterate called ContainerWidget-Links.cshtml and I'm trying to render the container widget like this:

 

<table class="linkContainer">
    <tr>
        <td>@title</td>
    </tr>
    @foreach (dynamic item in Model.ContentItems)
    {
        <tr>
        <td>
        @Display(item)
        </td>
        </tr>
    }

</table>

The problem I am running into is getting the title of the ContainerWidget.

If I knew how to access the ContainerWidget properties I could accomplish it.

Does anyone know?

Coordinator
Aug 3, 2012 at 1:13 PM

Model.ContentItem.TitlePart.Title should do the trick. Shape tracing could tell you for sure (look at the Model tab).

Aug 3, 2012 at 6:13 PM
bertrandleroy wrote:

Model.ContentItem.TitlePart.Title should do the trick. Shape tracing could tell you for sure (look at the Model tab).


I'm sorry, where do I find the model tab, I've tried looking at the Model object in the watch window and I can't find anything.

How do I do shape tracing?

Coordinator
Aug 3, 2012 at 6:41 PM

http://docs.orchardproject.net/Documentation/Customizing-Orchard-using-Designer-Helper-Tools

Aug 4, 2012 at 12:39 AM
Edited Aug 4, 2012 at 12:41 AM

Ok, getting there now I have this problem:

The title shows up twice:

File: Widget-ContainerWidget.cshtml

@using System.Text.RegularExpressions;
@using Orchard.Utility.Extensions;
@{
    String title = Model.ContentItem.WidgetPart.Title;

    Regex regEx = new Regex("/+(nvd_orchard(/?))?(?!.)", RegexOptions.IgnoreCase);
    }
@if (regEx.IsMatch(Request.Path))
{
    @title
    @Display(Model.Content)
}

Result:

I Want to...

I Want to...

Link 1

Link 2

Link 3

Any ideas why?

Coordinator
Aug 4, 2012 at 9:16 PM

You probably didn't uncheck the checkbox in the widget editor.

Aug 6, 2012 at 5:13 PM
Edited Aug 6, 2012 at 5:15 PM

I'm running orchard 1.3, there is no checkbox for the title.

 

I haven't been able to upgrade because I am using a module that won't work past 1.3.

But you're right I downloaded 1.5.1 and I saw the checkbox you're talking about, when I get the chance to upgrade I'll be able to make it work. Thank you.