Zoom - Professor Cloud Integration working fine

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
This  is correct code to work with more than 1 image.

OneVariant.ascx


        <script language="javascript" type="text/javascript">
            function UpdateMainImage(url, bigurl) {
                var imgMain = document.getElementById('zoom1');
                imgMain.href = url;
            }
            function showHref(elementID) {
                document.getElementById('fullview').href = document.getElementById(elementID).href;
                document.getElementById('fullview').title = document.getElementById(elementID).title;
            }
        </script>
        <div class="picture">
            <div class="productPictureMain">
                <script type="text/JavaScript" src="../Scripts/cloud-zoom.1.0.2.min.js"></script>
                <a href="" class='cloud-zoom' id="zoom1" rel="tint: '#ff0000',tintOpacity:0.2 ,smoothMove:5,zoomWidth:480, adjustY:-4, adjustX:10">
                    <asp:Image ID="defaultImage" runat="server" />
                </a>
            </div>
            <div class="productPictureOther">
                <asp:ListView ID="lvProductPictures" runat="server" GroupItemCount="1">
                    <LayoutTemplate>
                        <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
                    </LayoutTemplate>
                    <GroupTemplate>
                        <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
                    </GroupTemplate>
                    <ItemTemplate>
                        <a id="" onclick="showHref(this.id);" href="<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem)%>"
                            class="cloud-zoom-gallery" title="<%= lProductName.Text%>" rel="useZoom: 'zoom1', smallImage: '<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem, 390)%>' ">
                            <img src="<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem, 100)%>"
                                alt="Product image" /></a>
                    </ItemTemplate>
                </asp:ListView>
            </div>
            <script type="text/javascript">
                var i = 1;
                $(".productPictureOther a").each(function () {
                    $(this).attr('id', '' + i + '');
                    i++;
                });
                $(document).ready(function () {
                    $('#1').click();
                });
            </script>
            <a id="fullview" href="" rel="lightbox-p" title="">View Full Image</a>
        </div>


and codeBehind

OneVariant.ascx.cs


            if (this.SettingManager.GetSettingValueBoolean("Media.Product.DefaultPictureZoomEnabled", false))
            {
                var picture = product.DefaultPicture;
                if (picture != null)
                {
                    lvProductPictures.Attributes["href"] = this.PictureService.GetPictureUrl(picture);
                    lvProductPictures.Attributes["rel"] = "lightbox-pd";
                }
            }
        }
12 years ago
ProductInfo.ascx

<%@ Control Language="C#" AutoEventWireup="True" Inherits="NopSolutions.NopCommerce.Web.Modules.ProductInfoControl"
    CodeBehind="ProductInfo.ascx.cs" %>
<%@ Register TagPrefix="nopCommerce" TagName="ProductShareButton" Src="~/Modules/ProductShareButton.ascx" %>
<script language="javascript" type="text/javascript">
    function UpdateMainImage(url, bigurl) {
        var imgMain = document.getElementById('zoom1');
        imgMain.href = url;
    }
    function showHref(elementID) {
        document.getElementById('fullview').href = document.getElementById(elementID).href;
        document.getElementById('fullview').title = document.getElementById(elementID).title;
    }

</script>
<script src="../Scripts/cloud-zoom.1.0.2.min.js" type="text/javascript"></script>
<link href="../App_Themes/Majige_custom/cloud-zoom.css" rel="stylesheet" type="text/css" />
<div class="product-details-info">
    <div class="picture">
        <%-- <a href="" class='cloud-zoom' id="zoom1" rel="position: 'inside' , showTitle: false, adjustX:0, adjustY:0 " runat="server">
            
        </a--%>
        <asp:HyperLink ClientIDMode="Static" NavigateUrl="" CssClass='cloud-zoom' ID="zoom1" runat="server">
            <asp:Image ID="defaultImage" runat="server" />
        </asp:HyperLink>
    </div>
    <div class="overview">
        <h1 class="productname">
            <asp:Literal ID="lProductName" runat="server" />
        </h1>
        <div class="shortdescription">
            <asp:Literal ID="lShortDescription" runat="server" />
        </div>
        <div class="clear">
        </div>
        <asp:PlaceHolder runat="server" ID="phManufacturers">
            <div class="manufacturers">
                <asp:Literal ID="lManufacturersTitle" runat="server" />
                <asp:Repeater runat="server" ID="rptrManufacturers">
                    <ItemTemplate>
                        <asp:HyperLink ID="hlManufacturer" runat="server" Text='<%#Server.HtmlEncode(Eval("LocalizedName").ToString()) %>'
                            NavigateUrl='<%#SEOHelper.GetManufacturerUrl((Manufacturer)(Container.DataItem)) %>' />
                    </ItemTemplate>
                    <SeparatorTemplate>
                        ,
                    </SeparatorTemplate>
                </asp:Repeater>
            </div>
        </asp:PlaceHolder>
        <div class="clear">
        </div>
        <a id="fullview" href="" rel="lightbox-p" title="">View Full Size Image</a>
        <asp:ListView ID="lvProductPictures" runat="server" GroupItemCount="3">
            <LayoutTemplate>
                <div class="thumbnails">
                    <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
                </div>
            </LayoutTemplate>
            <GroupTemplate>
                <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
            </GroupTemplate>
            <ItemTemplate>
                <a id="" onclick="showHref(this.id);" href="<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem)%>"
                    class="cloud-zoom-gallery" title='<%= lProductName.Text%>' rel="useZoom: 'zoom1', smallImage: '<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem, 350)%>' ">
                    <img src="<%#this.PictureService.GetPictureUrl((Picture)Container.DataItem, 50)%>"
                        alt="Product image" /></a>
            </ItemTemplate>
        </asp:ListView>
        <div class="clear">
        </div>
        <div class="fulldescription">
            <asp:Literal ID="lFullDescription" runat="server" />
        </div>
        <nopCommerce:ProductShareButton ID="ctrlProductShareButton" runat="server" />
    </div>
    <script type="text/javascript">
        var i = 1;
        $(".thumbnails a").each(function () {
            $(this).attr('id', '' + i + '');
            i++;
        });
        $(document).ready(function () {
            $('#1').click();
        });
    </script>
</div>




Code Behind

//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
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.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Manufacturers;
using NopSolutions.NopCommerce.BusinessLogic.Media;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class ProductInfoControl : BaseNopFrontendUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                zoom1.Attributes.Add("rel", "position: 'inside' , showTitle: false, adjustX:0, adjustY:0 ");
            BindData();
        }

        protected void BindData()
        {
            var product = this.ProductService.GetProductById(this.ProductId);
            if (product != null)
            {
                lProductName.Text = Server.HtmlEncode(product.LocalizedName);
                lShortDescription.Text = product.LocalizedShortDescription;
                lFullDescription.Text = product.LocalizedFullDescription;

                //manufacturers
                List<Manufacturer> manufacturers = new List<Manufacturer>();
                foreach (var pm in product.ProductManufacturers)
                {
                    var manufacturer = pm.Manufacturer;
                    if (manufacturer != null)
                        manufacturers.Add(manufacturer);
                }
                if (manufacturers.Count > 0)
                {
                    if (manufacturers.Count == 1)
                    {
                        lManufacturersTitle.Text = GetLocaleResourceString("Products.Manufacturer");
                    }
                    else
                    {
                        lManufacturersTitle.Text = GetLocaleResourceString("Products.Manufacturers");
                    }
                    rptrManufacturers.DataSource = manufacturers;
                    rptrManufacturers.DataBind();
                }
                else
                {
                    phManufacturers.Visible = false;
                }

                //pictures
                var pictures = this.PictureService.GetPicturesByProductId(product.ProductId);
                if (pictures.Count > 1)
                {
                    defaultImage.ImageUrl = this.PictureService.GetPictureUrl(pictures[0], this.SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    lvProductPictures.DataSource = pictures;
                    lvProductPictures.DataBind();
                }
                else if (pictures.Count == 1)
                {
                    defaultImage.ImageUrl = this.PictureService.GetPictureUrl(pictures[0], this.SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    lvProductPictures.Visible = false;
                }
                else
                {
                    defaultImage.ImageUrl = this.PictureService.GetDefaultPictureUrl(this.SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                    lvProductPictures.Visible = false;
                }
                if (this.SettingManager.GetSettingValueBoolean("Media.Product.DefaultPictureZoomEnabled", false))
                {
                    var picture = product.DefaultPicture;
                    if (picture != null)
                    {
                        //lnkMainLightbox.Attributes["href"] = this.PictureService.GetPictureUrl(picture);
                        //lnkMainLightbox.Attributes["rel"] = "lightbox-pd";
                        zoom1.Attributes.Add("rel", "position: 'inside' , showTitle: false, adjustX:0, adjustY:0 ");
                        zoom1.Attributes["href"] = this.PictureService.GetPictureUrl(picture);
                    }
                }
            }
            else
                this.Visible = false;
        }

        protected override void OnPreRender(EventArgs e)
        {
            BindJQuery();

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

            base.OnPreRender(e);
        }

        public int ProductId
        {
            get
            {
                return CommonHelper.QueryStringInt("ProductId");
            }
        }
    }
}
12 years ago
Great effort! I've been following the topic since the beginning and know how much effort has been put into this functionality. However I am confused by what seems two different solutions in two different places in the code.

Wx Development posted his solution in the OneVariant page, while KambuiNurse chose to do it in ProductInfo.

Have you two collaborated on this or arrived at two different solutions separately and just happen to work in different pages?

What is the difference? Which is really the most appropriate to use?


Thanks for your effort! I eagerly await feedback from others that have been following the discussion; especially if one of the development team could provide a little insight on the best approach.
12 years ago
rober4t wrote:
Great effort! I've been following the topic since the beginning and know how much effort has been put into this functionality. However I am confused by what seems two different solutions in two different places in the code.

Wx Development posted his solution in the OneVariant page, while KambuiNurse chose to do it in ProductInfo.

Have you two collaborated on this or arrived at two different solutions separately and just happen to work in different pages?

What is the difference? Which is really the most appropriate to use?


Thanks for your effort! I eagerly await feedback from others that have been following the discussion; especially if one of the development team could provide a little insight on the best approach.


Wow good text thanks!
I been doing in OneVariant page because I choose to have my tamplate on it. I think  KambuiNurse used ProductInfo because hee usen VariantsInGrid Template. basically is the same job on 2 different templates =)
12 years ago
rober4t wrote:

Wx Development posted his solution in the OneVariant page, while KambuiNurse chose to do it in ProductInfo.

What is the difference? Which is really the most appropriate to use?


The code for "ProductInfo" is used for the "Variants In Grid" template.
You don't need to use Variants in Grid unless you have added Variants to the product.

The code in "OneVariant"  is used for the "Single Product Variant" template.
This is the one you will be using most of the time when the Product does not
have any product variants.
So unless you use product variants, you don't even need to worry about the "ProductInfo" page.
12 years ago
Thanks a bunch for the clarification. I think i'll go play with it now.
And thanks to those determined and dedicated KambuiNurse and WxDevelopment for their dogged pursuit of this solution!

All of you are awesome!

Thanks

Robert L
12 years ago
I cant get this to work...

i tried all the examples in the thread...
12 years ago
Can you provide some details ?
12 years ago
Can someone upload on rapidshare the working code? It seems it is very hard to know which code works and which one doesn't.
P.S: Does the nopcommerce forum administration plan to let user upload files in the forum? It will help a lot!
12 years ago
akumiro wrote:
P.S: Does the nopcommerce forum administration plan to let user upload files in the forum? It will help a lot!


They will not do this.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.