Create product tab for one attribute while leaving the others on another tab


https://forum.kartris.com/Topic1263.aspx
Print Topic | Close Window

By saturation - Thu 25 Aug 2011
I need to create a separate tab on the product view specifically for one attribute and leave the other attributes in the other attributes tab.   Any idea on how to do this?
By Mohammad - Fri 26 Aug 2011
There are different ways to do that, here is a simple one:

1. Use the "Front\ProductAttributes.ascx" as a guide to create another attribute control (for your chosen one) - (preferably to copy the control, and then give it another name like 'SeparateAttribute.ascx')

2. Create a new tab in the "Front\ProductView.ascx" control and place an instance of the created control in step no.1 above, don't forget to register the control at the top of the ProductView.ascx page, check the file for more details on how to do that.

Let us say your chosen attribute (that needs to be alone in the new tab) has the db ID (ATTRIB_ID) = 20

3. In "Front\ProductAttributes.ascx.vb"
Change this:
rptAttributes.DataSource = tblAttributes.DefaultView
rptAttributes.DataBind()

By this:
Dim dv As DataView = tblAttributes.DefaultView
dv.RowFilter = "ATTRIB_ID <> 20"
rptAttributes.DataSource = dv
rptAttributes.DataBind()


4. In the newly created control
Change this:
rptAttributes.DataSource = tblAttributes.DefaultView
rptAttributes.DataBind()

By this:
Dim dv As DataView = tblAttributes.DefaultView
dv.RowFilter = "ATTRIB_ID = 20"
rptAttributes.DataSource = dv
rptAttributes.DataBind()


Save your changes and here you go ..

There are other alternative ways, one could be applied to the same control, but it will be a bit confusing, another will require changing or creating stored procedures (if you have too many attributes), but the above one is very simple and straight forward if you have couple of attributes rather than many attributes.
By saturation - Tue 30 Aug 2011
Ok, I was able to get the tab into place, but now it's not showing any data.   I followed the instructions you suggested.   It also appears that the other tab (the original attributes tab) still shows all of the attributes--even with the rowfilter set

dv.RowFilter = "ATTRIB_ID <> 20"

Do I need to query the database for something else than 20?  I'm not sure how this query works.
By Mohammad - Wed 31 Aug 2011
Yeah the "20" need to be changed, as I told you in my previous post, it is the id of the attribute that you need to show in separate tab. Use the view "vKartrisTypeAttributes" to know the needed ATTRIB_ID and replace the "20" in both codes with that ATTRIB_ID.
By saturation - Thu 1 Sep 2011
Got it....And it's working great!   Thank you so much Mohammad!