This project is read-only.

Widget not showing up

Topics: Writing modules
May 7, 2012 at 3:57 PM

I have created a widget that has no storage, just a driver that overrides the display method.  It gets its data fro a service that is injected into the driver.  I can place the widget on a page but nothing shows up.  During page load, the driver code and the view code never get executed.  Below is the code.  I must be missing something, but I don't know what.


using Orchard.ContentManagement;

namespace ThorTech.RestaurantGeoSearch.Models
    public class MarketsWidgetPart : ContentPart



using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using ThorTech.RestaurantGeoSearch.Models;
using ThorTech.RestaurantGeoSearch.Services;

namespace ThorTech.RestaurantGeoSearch.Drivers
    class MarketsWidgetDriver : ContentPartDriver<MarketsWidgetPart>
         private readonly IMarketsService _markets;

         public MarketsWidgetDriver(IMarketsService markets)
             _markets = markets;

        protected override DriverResult Display(MarketsWidgetPart part, string displayType, dynamic shapeHelper)
            return ContentShape("Parts_MarketsWidget", () => shapeHelper.Parts_MarketsWidget(
                Markets: _markets.Markets,
                SelectedMarket: _markets.SelectedMarket




@using ThorTech.RestaurantGeoSearch.Models

    var markets = (IEnumerable<MarketRecord>)Model.Markets;
    var selectedmarket = (MarketRecord) Model.SelectedMarket;

    // get the market names from the passed in markets enum
    var marketnames = markets.Select(r => r.Name).Distinct().ToList();

IN MarketsWidget
@using (Html.BeginForm("SetMarket", "Markets", FormMethod.Get, new { id = "marketForm" }))
    @Html.DropDownList("marketName", new SelectList(marketnames, selectedmarket.Name), new { id = "multi_city", name = "multi_city", onchange = "document.getElementById('marketForm').submit();" }) 

<?xml version="1.0" encoding="utf-8" ?>
    <Place Parts_Common_Metadata="-"/>
    <Place Parts_Common_Metadata_Summary="-"/>
    <Place Parts_Restaurant_Edit="Content:10"/>
    <Place Parts_RestaurantGeoSearch_SiteSettings="Content:1"/>
    <Place Parts_MarketsWidget="Content:1"/>



            // Create a new widget content type with our market widget part
            ContentDefinitionManager.AlterTypeDefinition("MarketsWidget", cfg => cfg
                .WithSetting("Stereotype", "Widget"));


Any help would be greatly appreciated.

May 7, 2012 at 4:02 PM
Edited May 7, 2012 at 4:03 PM

Nevermind...  duh...


class MarketsWidgetDriver : ContentPartDriver<MarketsWidgetPart>

should be

public class MarketsWidgetDriver : ContentPartDriver<MarketsWidgetPart>