Rank: Newbie
Groups: Developers, Registered, HelpDesk Joined: 6/20/2019(UTC) Posts: 3
Thanks: 1 times
|
Seeking to create 400+ products each with unique html content. Tried HTML Snippet widget, but that seems best suited for repeatable shared content, and I would have to create 400+ of them . I have to assume that Webpage Content widget is closer to my task, but once placed, will not allow for editing, and there is no documentation that I can find to guide me, so in absence of other data it appears to not be working. Edited by moderator Monday, July 8, 2019 1:57:39 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, System, Admin Joined: 10/18/2018(UTC) Posts: 183
Thanks: 1 times Was thanked: 6 time(s) in 6 post(s)
|
Hello,
Why is the product description or the more details not suitable for the task?
Please explain your goals and we can provide some assistance. |
|
|
|
|
Rank: Newbie
Groups: Developers, Registered, HelpDesk Joined: 6/20/2019(UTC) Posts: 3
Thanks: 1 times
|
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, System, Admin Joined: 10/18/2018(UTC) Posts: 183
Thanks: 1 times Was thanked: 6 time(s) in 6 post(s)
|
Hello,
The webpage widget is setup to be embedded into a webpage, we had not thought about embedding a webpage into a product. It would need a new attribute webpageid in order to do what you are wanting. |
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Can you use Razor syntax on the product page? For example, some code that was converted from AC5 vb code to use on _BuyProductDialog.cshtml. This is the best I could come up with without having to add code to cause site to recompile and with little documentation. It seems using Razor syntax could paralell what you would do in nVelocity. Quote: @model BuyProductDialogModel @using CommerceBuilder.Products @{ RequireScript("~/scripts/option_picker.js"); RequireScript("~/scripts/jquery-easing/jquery.easing.min.js"); RequireScript("~/scripts/custom/buy-product-dialog.js"); //jme 061319 custom from AC5 site Product product = AbleContext.Container.Resolve<IProductRepository>().Load(Model.Product.Id); string description = product.Description; string extendedDescription = product.ExtendedDescription; string mainStyle = ""; string mainKeywords = "";
string leftPart = ""; string rightPart = ""; int i = 0; if (extendedDescription!=null && extendedDescription.Length > 0) { string[] parts = extendedDescription.Split("||".ToCharArray());
while (i < parts.Length-1) { leftPart = parts[i]; rightPart = ""; i = i += 1; if(i<=parts.Length) { rightPart = parts[i+1]; } if (leftPart == "webtext") { extendedDescription = rightPart; } else if (leftPart=="style") { mainStyle = rightPart; } else if(leftPart=="keywords") { mainKeywords = rightPart; } i = i += 1;
}
}
Later on, a couple of the variables are used. Quote: <span>@Html.Raw(mainStyle) @Html.Raw(description)</span>
Possibly something like the following:-last line is existing AC code I left in so you could see how to nest it Quote: if (product.TemplateFields.Count > 0) { foreach (ProductTemplateField tf in product.TemplateFields) {
if (tf.InputField.Name == "xx") { <span>@Html.Raw(tf.InputValue)</span> } } }
if (Model.ShowProductReviews && AbleContext.Current.Store.Settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None)
|
1 user thanked judy at Web2Market for this useful post.
|
|
|
Rank: Newbie
Groups: Developers, Registered, HelpDesk Joined: 6/20/2019(UTC) Posts: 3
Thanks: 1 times
|
Thanks to judy13846, spent the last month getting up to speed on ASPNET and RAZOR, tools I have not used before now.
Although I cannot actually run the demo code (all Macs, no place to run SQL server), I was able to study the example files and simulate a TemplateFields collection. I have determined that the following code will handle the template fields as I require, placed into the _ProductPage.cshtml file:
First, adding the reference to the top:
@using CommerceBuilder.Products
and then strategically placing the following logic (stripped of most of the html tags for clarity here):
Product product = AbleContext.Container.Resolve<IProductRepository>().Load(Model.Product.Id); @{ var aCnt = 0; var mCnt = 0; var CRight = "";
if (Model.tif.Count > 0) {
{ foreach (ProductTemplateField tf in product.TemplateFields) { if (@aCnt == 0) { CRight = tf.InputValue; aCnt++; mCnt = 0; } else { if (@mCnt == 0) { <b>Label</b><B>@tf.InputValue</B><br /> } if (@mCnt == 1) { <b>Audio</b><B>@tf.InputValue</B> }
if (@mCnt == 2 && @tf.InputValue != "") { <b>Video</b><B>@tf.InputValue</B> } if (@mCnt == 3 && @tf.InputValue != "") { <b>Embed</b><B>@tf.InputValue</B> } mCnt++; if (@mCnt == 4) { <br /><br /> mCnt = 0; } } }
} } <h3>Copyright @CRight</h3> }
Worked perfectly in my VS tests, using dynamic array as standin for PRoduct object, fields collection. Will check with Mike to see if I can get this added to a page in my most recent demo site.
Thanks again for the guidance.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close