Suggestion for cart : enable lightbox for product with single images

10 years ago
lightbox is a fabulous tool - my details page shows a smaller image than the uploaded original and you can only see this larger version if you have more than one image uploaded for a particular item

i think it would be great if clicking the image on the 'details' page could bring up the full size image in lightbox even if its the only one uploaded
10 years ago
\NopCommerceStore\Modules\ProductInfo.ascx.cs

In the BindData() method change

   if (productPictures.Count > 1) to:
   if (productPictures.Count >= 1)

remove:

     else if (productPictures.Count == 1)
                {
                    defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureID, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    lvProductPictures.Visible = false;
                }


UNTESTED.
10 years ago
The code above doesn't appear to work, do you mind having another quick look please?

We would like to have the possibility of enlarging the image even when only one is present also.

Thanks in advance.
10 years ago
Have you recompiled the solution?

The provided code change should work as I have been using functionally equivalent code for some time:
if (productPictures.Count > 0)

and I commented out the else if block (instead of deleting it).

.
10 years ago
Thanks for the reply.

Yes I did force a re-compile by stopping the IIS service and then removing the corresponding files from the Microsoft.NET 'Temporary ASP.NET Files' folder. This is the correct way to do it?

Still no luck however and the lightbox still will not show for single image products.

ProductInfo.ascx.cs reads as follows:

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Media;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class ProductInfoControl : BaseNopUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                BindData();
        }

        protected void BindData()
        {
            Product product = ProductManager.GetProductByID(ProductID);
            if (product != null)
            {
                lProductName.Text = Server.HtmlEncode(product.Name);
                lShortDescription.Text = product.ShortDescription;
                lFullDescription.Text = product.FullDescription;

                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 0)
                {
                    defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureID, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    lvProductPictures.DataSource = productPictures;
                    lvProductPictures.DataBind();
                }
                else
                {
                    defaultImage.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    lvProductPictures.Visible = false;
                }
            }
            else
                this.Visible = false;
        }

        protected override void OnPreRender(EventArgs e)
        {
            string jquery = CommonHelper.GetStoreLocation() + "Scripts/jquery-1.3.2.min.js";
            Page.ClientScript.RegisterClientScriptInclude(jquery, jquery);

            string slimBox = CommonHelper.GetStoreLocation() + "Scripts/slimbox2.js";
            Page.ClientScript.RegisterClientScriptInclude(slimBox, slimBox);

            base.OnPreRender(e);
        }

        public int ProductID
        {
            get
            {
                return CommonHelper.QueryStringInt("ProductID");
            }
        }
    }
}
10 years ago
That looks correct.  Did you copy over the DLL to the correct place or is IIS pointing to the same directory.  You could also try "rebuild" which will force all the dll to re compile.
10 years ago
why not upload the same image twice?. No code changes needed :)
10 years ago
Seems pointless when its a minor code change?
10 years ago
Where can i find the 'rebuild' option? We do not have VSS installed - just editing the raw files in Notepad...
10 years ago
skiltz -->
completely missed the replies to this topic - just made the changes & it works perfectly, exactly what i was after -  thanks again

solidata -->
i used the beta release of VS2010 to recomplie the project