Products sample questions

Posted by Community Admin on 03-Aug-2018 21:52

Products sample questions

All Replies

Posted by Community Admin on 15-Jun-2012 00:00

Hello.

I just created custom module based on Products sample from the SDK.

I would like to add the following some functionality:

In the backend “Grid View Mode” I want add one more column representing, lest say, products color. Products color field tied to the “Colors” taxonomy. In my case it is single choice. If it is possible, could you please provide code sample how to add such column.

 

Also, I would like to add filtration functionality by color in the side bar. My experiments didn’t work. In the definitions file I found place where “filter by tags” option is added. I simply tried to replace "Tags" taxonomy id with the "Colors" taxonomy id:

            var clientTemplateBuilder = new System.Text.StringBuilder();
            clientTemplateBuilder.Append(@"<a href=""javascript:void(0);"" class=""sf_binderCommand_filterByTag");
            clientTemplateBuilder.Append(@""">Title</a> <span class='sfCount'>(ItemsCount)</span>");
            var tagFilterWidget = new DynamicCommandWidgetElement(tagFilterSection.Items)
            
                Name = "TagFilter",
                CommandName = "filterByTag",
                PageSize = 10,
                WidgetType = typeof(DynamicCommandWidget),
                IsSeparator = false,
                BindTo = BindCommandListTo.Client,
                //I modified next line
                BaseServiceUrl = String.Format("~/Sitefinity/Services/Taxonomies/FlatTaxon.svc/0/", "8B121C60-692F-45B3-8E87-05D35F696E92"),
                ResourceClassId = typeof(Labels).Name,
                MoreLinkText = "ShowMoreTags",
                MoreLinkCssClass = "sfShowMore",
                LessLinkText = "ShowLessTags",
                LessLinkCssClass = "sfShowMore",
                SelectedItemCssClass = "sfSel",
                ClientItemTemplate = clientTemplateBuilder.ToString()
            ;
            tagFilterWidget.UrlParameters.Add("itemType", typeof(PortfolioItem).AssemblyQualifiedName);
 
            tagFilterSection.Items.Add(tagFilterWidget);
 
...
            DefinitionsHelper.CreateTaxonomyLink(
                new Guid("8B121C60-692F-45B3-8E87-05D35F696E92"),  //And this line
                DefinitionsHelper.HideSectionsExceptCommandName,
                DefinitionsHelper.ConstructDisplaySectionsCommandArgument(tagFilterSection.WrapperTagId),
                sidebarSection);

After this the link on the side bar shows correct taxons from the Colors taxonomy, but when I clink on one of them, the main grid becomes empty and says "no items to display". Although I have items assigned to the Colors taxons.
Please let me know the correct way to implement this functionality. Code samples are appreciated.

Thanks!
Denis.

This thread is closed