Developer forum

Forum » Ecommerce - Standard features » Product images

Product images

Thomas Schroll
Reply

Hi

I'm linking to products from an article based on an Item with product item fields (product type).

@foreach(string productID in products){
    var product = Product.GetProductByID(productID);
    <a href="productlist?ProductID=@product.ID" title="@product.Name">
        @if(!string.IsNullOrEmpty(product.ImageLarge)){
            <span class="span2">
                @product.ImageLarge
            </span>
        }
    </a>
    <h5>
        <a href="productlist?ProductID=@product.ID" title="@product.Name">@product.Name</a>
    </h5>
}

where products is an array of product Id's

The problem is that I'm using the Alt. image functionality in my product catalog, which mean that the ImageLarge value is empty.

Does anybody know how I can show the images?

Also I would like to know why there is 'p_' before product id's and a ':' after the last product id in a list of attached products? Because of that I need to do the following:

string[] products = post.GetString("ItemPublisher:Item.Products").Replace("p_","").Replace(":","").Split(',');

to get the product id's into an array. Is there a better way to do this?

Regards Thomas

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Thomas

You can use the general image pattern setting in the control panel as fall back:

http://manual.dynamicweb-cms.com/Default.aspx?ID=7208

The P_{id} format on the field is how they are stored in the database. You should not access that value directly from your template. Instead you have a loop with the name of your product field. Iterate that and you get a loop of product instances including all the context information like prices etc.

Nicolai

 
Thomas Schroll
Reply

Hi Nicolai

I didn't see the product loop because it is under Items.List, sorry.

However, I can't find the image tag in the product list. Here's what is generated by TemplateTag():

Ecom:Product.Form.Clean
Ecom:Product.Form
Ecom:Product.Form.Multi.HiddenFields
Ecom:Product.LoopCounter
Ecom:Product.Link.PID
Ecom:Product.Link.Clean.PID
Ecom:Product.Link
Ecom:Product.Link.Clean
Ecom:Product.LinkGroup
Ecom:Product.LinkGroup.Clean
Ecom:Product.LinkGroup.PID
Ecom:Product.LinkGroup.Clean.PID
Ecom:Product.ID
Ecom:Product.ID.UrlEncoded
Ecom:Product.Number
Ecom:Product.DefaultVariantComboID
Ecom:Product.Name
Ecom:Product.CompareID
Ecom:Product.Rating
Ecom:Product.RatingStars
Ecom:Product.CommentCount
Ecom:Product.MetaTitle
Ecom:Product.MetaKeywords
Ecom:Product.MetaDescription
Ecom:Product.MetaUrl
Ecom:Product.VATGroup
Ecom:Product.DBPrice
Ecom:Product:Page.ID
Ecom:Product.Created
Ecom:Product.Updated
Ecom:Product.ShortDescription.Raw
Ecom:Product.ShortDescription
Ecom:Product.Link1
Ecom:Product.Link2
Ecom:Product.LongDescription
Ecom:Product.Volume
Ecom:Product.Weight
Ecom:Product.PriceType
Ecom:Product.Type
Ecom:Product.PriceCount
Ecom:Product.VariantCount
Ecom:Product.LanguageID
Ecom:Product.VariantID
Ecom:Product.VariantID.Extented
Ecom:Product.DefaultShopID
Ecom:Product.DefaultUnitID
Ecom:Product.ReservedAmount
Comments.TotalCount
Comments.Count
Comments.RepliesCount
Comments.Rating
Comments.Rating.Rounded
Comments.Rating.Rounded2
Comments.Stars
eCom:Related.ProductSmartSearches.Count
eCom:Related.SavedForLater.Count
eCom:Related.WhatAboutTheseProducts.Count
eCom:Related.CustomersWhoSawThisAlsoSaw.Count
eCom:Related.CustomersWhoBoughtThisItemAlsoBought.Count
eCom:Related.MostPopularProducts.Count
eCom:Related.YouHaveSeenTheseProducts.Count
ItemPublisher:Item.Products.LoopCounter
ItemPublisher:Item.Products.LoopMod2
ItemPublisher:Item.Products.LoopMod3
ItemPublisher:Item.Products.LoopMod4
ItemPublisher:Item.Products.LoopMod5
parentLoopIndex
Loops
Comments
ProductCategories

 

Regards Thomas

 

You must be logged in to post in the forum