Page 1 of 1

ConLib / Scriptlet for ProductPage - Specific Product

Posted: Thu Jan 31, 2013 5:09 pm
by FirstDivision
While trying to integrate Able functionality with another CMS I have run into a bit of a stumbling block:

I have been able to create a wrapper for the "HtmlContainer" CommerceBuilder control, and through our wrapper pass the ConLib/Scriptlet language into the HtmlContiner value property.

This works for the most part, for example I can show the Featured Products by passing in:

Code: Select all

[[ConLib:FeaturedProductsGrid Caption="Featured Items" Size="2" Columns="2" IncludeOutOfStockItems="false" ThumbnailPosition="LEFT" Orientation="HORIZONTAL"]]
or an Add To Cart link by passing:

Code: Select all

[[ConLib:AddToCartLink ProductId="52"]]
What I can't get to work, in either our CMS or Able itself is the ProductPage or ProductImage scriptlets. What I want to do is show a specific product by ID. The documentation shows using the ProductImage scriptlet like:

Code: Select all

[[ConLib:ProductImage ShowImage="Thumbnail" Product=""]]
I've tried passing both integer values and the whole "product url" into the Product="" property, but I haven't been able to get the sciptlet to product anything besides an error, specifically: " Invalid cast from 'System.String' to CommerceBuilder.Products.Product'."

Edit: I have also tried the ProductPage ConLib with the Product="" attribute like above and get the same exception as output.

Any ideas here?

TL;DR: If I wanted to show a specific product image (or ProductPage) on an "Able Webpage", how would I go about that via Scriptlet / ConLib? The answer to that should be the same as what I'm trying to do.

Thanks.

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Thu Jan 31, 2013 6:52 pm
by Logan Rhodehamel
I can tell you that the difficulty with the parameter you want to pass is that the ConLib is expecting an object, rather than a string or an integer. I checked ProductImage scriptlet and it doesn't have a way to do what you want right now. However it might not be too hard to fit it in. The code behind just needs a new property added so you can pass in a ProductId. And then the Product property needs to respect this possibility.

Does this make sense? If you like I can try to help you along with the code changes needed. The situation is likely similar for the ProductPage control.

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Thu Jan 31, 2013 8:34 pm
by FirstDivision
Yeah, pretty much that was my suspicion. It's looking for a serialized product I guess? What did you mean by yet?

So maybe my only option at this point is to create my own control that will do what I want? I'm still learning this, but it seems that maybe the name of the control and the associated properties are mapped directly to the Scriptlet syntax? So if I implement my own, the Scriptlet might look like:

Code: Select all

[[ConLib:MyControl ProductId="52" SomethingElse="2"]]
And that would map to an ascx down in the ConLib folder named MyControl.ascx with public properties of ProductID and SomethingElse? I don't think there are any special inheritance requirements unless I want to use...ISideBar interface (or something like that)?

My main (i.e ultimate) goal would probably be to re-implement the ProductPage control, but that has other nested controls, so what would I have to do to make sure that any nested controls can pick up the product (without having to be "picked up" by product.aspx first) and totally divorce it from any layout dependancies?

I hope my questions make sense, as I said I'm just learning how all this fits together...

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Fri Feb 01, 2013 8:01 am
by jmestep
Is this Able 7 or Gold? Question is in the Gold topic, but something like the following isn't applicable to Gold, even though the conlib reference in the admin still shows it.
[[ConLib:FeaturedProductsGrid Caption="Featured Items" Size="2" Columns="2" IncludeOutOfStockItems="false" ThumbnailPosition="LEFT" Orientation="HORIZONTAL"]]

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Fri Feb 01, 2013 10:13 am
by FirstDivision
I'm working with Gold. Now I'm not sure what to do...what's the correct way to do what I want in Gold?

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Fri Feb 01, 2013 11:32 am
by FirstDivision
Well, until I hear otherwise I think I'm on my way. I created a copy of ProductImage.ascx and called it ProductImageByID.ascx, then I added a property:

Code: Select all

       
[Personalizable(), WebBrowsable()]
public int ProductID
{
	get
	{
		return _ProductId;
	}
	set { 
		_ProductId = value;
		_Product = ProductDataSource.Load(_ProductId);
	}
}
This has gotten me to where I can load it via Scriptlet like:

Code: Select all

[[ConLib:ProductImageByID ProductID="52"]]
I think from here I should be able to go all the way to creating a copy of the ProductPage control, but have it accept an ID as well.

Re: ConLib / Scriptlet for ProductPage - Specific Product

Posted: Fri Feb 01, 2013 12:26 pm
by Logan Rhodehamel
Yeah you are on the right track. Your change allows the scriptlet to accept a parameter that can be represented via string.

Judy, in the initial post it says they have created a wrapper for HtmlContainer. I'm not sure what the customization is but HtmlContainer has support for ConLib refrences.