Hi there,
Looking for a bit of help to get over a small hurdle.
I am trying to do a variation of product specifications for displaying highlighted features. I had done this as part of the core in 3.2... but now in 3.4 trying to do this as a plugin.
I setup an Event folder and class and put in the HandleEvent to trap for the TabStripName
...
public void HandleEvent(AdminTabStripCreated eventMessage)
{
if (eventMessage.TabStripName == "product-edit")
{
WidgetsProductHighlightsController controller = new WidgetsProductHighlightsController(_workContext, _storeContext, _storeService, _settingService, _cacheManager, _highlightAttributeService, _languageService, _localizedEntityService, _localizationService, _customerActivityService, _permissionService, _productService);
string res = controller.LoadProductTab();
eventMessage.BlocksToRender.Add(new System.Web.Mvc.MvcHtmlString(res));
}
}
In my Controller...the loadProductTab function
public string LoadProductTab()
{
if (ControllerContext == null)
{
ControllerContext context = new ControllerContext(System.Web.HttpContext.Current.Request.RequestContext, this);
ControllerContext = context;
}
//some stuff to populate a model
return this.RenderPartialViewToString("~/Plugins/Widgets.ProductHighlights/Views/WidgetsProductHighlights/Test.cshtml", model);
}
Then the Test.cshtml file
...
<table class="adminContent">
<tr>
<td>
<script>
$(document).ready(function () {
AddTab('Product Highlights');
});
function AddTab(title) {
var kTabs = $("#product-edit").data("kendoTabStrip");
kTabs.append({ text: title, contentUrl: "@Url.Content("~/Plugins/Admin/ProductHighlights")" });
}
</script>
</td>
</tr>
</table>
~/Plugins/Admin/ProductHighlights points to the controller which returns the view List() for the highlight attribute grid for a product.
The issue is... once I click on my tab in the strip, it seems to work partially, except that the Selected Tab is always the Product Info tab (1st tab) and if I do any interaction at all, things seem to go off the rails.
Questions:
1. How do I make sure the selected tab stays selected?
2. Overall above...is this the proper best practice/best way to accomplish what I am doing?
Once I get all this pieced together, I will drop this into the new documentation section. It would be useful to have plugin documentation for stuff like this - interacting with the product tab, and adding product "things" in admin that would be visible via a widget on the front end.
Thanks