Adding PDF Brochures, Informationals, etc.

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Fri Dec 30, 2011 4:48 pm

Is there a way I can attach PDFs to each product? I have a site that will need to attach a PDF safety manual to every single product and have it available to download on each product's page. I think the easiest way would be to attach the specific PDF to the specific product so only that particular PDF is displayed on the product's page. Then I'm assuming I can just create a ConLib (?) to reference that product's PDF somewhere on the Product Display?

The only problem is trying to figure out how to attach these PDFs to each product.

I think they also want a library page somewhere where a user can go and all these PDFs are returned to them in a list view.

Thanks for any pointers.

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Adding PDF Brochures, Informationals, etc.

Post by david-ebt » Fri Dec 30, 2011 7:00 pm

You can use product custom fields or product template fields to hold additional attributes for a product. Based on what you've described, I would recommend product custom fields. Take a look at these two forum threads for some help on how to modify the admin to give you a place to manage the additional field and how to use the field on our product page.

Admin: viewtopic.php?f=47&t=12056

Product Page: viewtopic.php?f=42&t=16034

If you look at the FAQ control in the second post, you would change the asp:Label to asp:HyperLink and set the NavigateUrl to the value in our custom field.

I hope that helps!
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Re: Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Mon Jan 02, 2012 9:52 am

Thanks, again, David. I'll be trying this out today.

RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Re: Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Mon Jan 02, 2012 11:15 am

Ok. So I was trying it out and reading through the forums you suggested. I think I may have not communicated exactly what I was looking for. I do want to add the custom field, so that's there for me to follow, but the field is really an admin upload field. So on the edit product page, maybe under More Details, there's the standard upload field with a browse button etc next to it. So the admin clicks "browse" locates the file on their computer, then when they save the product that upload is added to the product for someone to download from the product display page.

What I've done thus far is edit the EditProducts.aspx and that gives me the blank url next to the Field Title. I'm betting I just don't know the correct asp value to render it the way I want. Probably something easy like asp:upload *******hopefully******* but then again, I might be in a world or complexity here.

I know this sounds like file downloads, but I think that whole section is set up to sell downloads or to add them as products. My need is just to have them as an addon to each product. See what I mean?

RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Re: Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Mon Jan 02, 2012 3:40 pm

I've tried following those threads you posted but they just result in Runtime errors. I've posted there as well just in case they see it but I don't have any idea what's wrong. I follow them EXACTLY and all I get are runtime errors. I'm using AbleCommerce 7.0.5 build 14053.

I've searched for custom fields all throughout AbleCommerce and Google but so far I haven't turned up anything helpful. Everything is runtime errors no matter what.

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Adding PDF Brochures, Informationals, etc.

Post by david-ebt » Mon Jan 02, 2012 4:47 pm

If you want admin users to be able to upload the file then you will need the file upload feature. The other option is for someone to directly copy/ftp the files into a folder (i.e. assets) and then you only have to reference the file. Here is some code snippets to get you started on a feature to let the admin upload the file.

code for the admin page that will display the upload button and field

Code: Select all

<div class="UploadPDF">
    <asp:FileUpload ID="FileUpload1" runat="server" /><br />
    <asp:Button ID="buttonUpload" runat="server" Text="Upload" OnClick="UploadButton_Click" /><br />
</div>
code for the admin .cs page. this assumes you have an "assets\pdf" directory for your files. You may need to adjust permissions on the assets\pdf folder so that IIS can write to that folder. You can change this as required.

Code: Select all

protected void UploadButton_Click(object sender, EventArgs e)
{
	if (FileUpload1.HasFile)
	{
		string theFileName = Path.Combine(Server.MapPath("~/Assets/PDF/"), FileUpload1.FileName);
		if (File.Exists(theFileName))
		{
			File.Delete(theFileName);
		}
		FileUpload1.SaveAs(theFileName);
	}
}
You'll also need to add this reference to the top of the .cs file:

Code: Select all

using System.IO;
As written, this doesn't provide any feedback to the admin user that file upload was successful or not.
Last edited by david-ebt on Fri Jan 06, 2012 6:51 pm, edited 1 time in total.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Adding PDF Brochures, Informationals, etc.

Post by jmestep » Tue Jan 03, 2012 8:58 am

You can also name the pdfs similar to the products sku or productid and put a link on the product page based on that. Then upload the pdfs via ftp. We have done that with manufacturer logos for someone and we didn't have to create an admin or upload interface. For example, if your product id is 1234, the link would be 1234.pdf and you would create it something similar to url = product.ProductId.ToString() + ".pdf"
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Re: Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Wed Jan 04, 2012 5:13 pm

I tried what you said, David, and I get a "Path does not exist in this context" error for the .cs.

Here's my EditProduct.aspx:

Code: Select all


<%@ Page Language="C#" MasterPageFile="~/Admin/Products/Product.master" AutoEventWireup="true" CodeFile="EditProduct.aspx.cs" Inherits="Admin_Products_EditProduct" Title="Edit Product '{0}'" %>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls" TagPrefix="cb" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

<table cellpadding="3" cellspacing="0" class="inputForm" width="100%">

...

<tr>
        <th class="rowHeader" style="vertical-align:top;">
            <asp:ImageButton ID="ExtendedDescriptionHtml" runat="server" AlternateText="Edit HTML" ToolTip="Edit HTML" SkinID="HtmlIcon" OnClientClick="" CausesValidation="False" />&nbsp;
            <cb:ToolTipLabel ID="ExtendedDescriptionLabel" runat="server" Text="More&nbsp;Details:" ToolTip="More details or additional description for this product."></cb:ToolTipLabel>
        </th>
        <td colspan="3">
            <asp:TextBox ID="ExtendedDescription" runat="server" Columns="120" Height="200px" TextMode="multiLine" />
        </td>
    </tr>
    <tr>
        <th class="rowHeader" style="vertical-align:top;">
            <cb:ToolTipLabel ID="MSDSLabel" runat="server" Text="MSDS" ToolTip="Upload New MSDS for this product."></cb:ToolTipLabel>
        </th>
        <td colspan="3">
            <asp:FileUpload ID="MSDS" runat="server" Columns="120" Height="200px" TextMode="multiLine" Visible="false"  />
            <asp:Button ID="ButtonUpload" runat="server" Text="Upload" OnClick="UploadButton_Click" />
        </td>
    </tr>
...
And here's my EditProduct.aspx.cs

Code: Select all


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Common;
using CommerceBuilder.Catalog;
using CommerceBuilder.Products;
using CommerceBuilder.Shipping;
using CommerceBuilder.Stores;
using CommerceBuilder.Utility;

public partial class Admin_Products_EditProduct : CommerceBuilder.Web.UI.AbleCommerceAdminPage
{
    private int _ProductId = 0;
    private Product _Product;

    protected void Page_Init(object sender, EventArgs e)
    {
        _ProductId = PageHelper.GetProductId();
        _Product = ProductDataSource.Load(_ProductId);
        Page.Title = string.Format(Page.Title, _Product.Name);
        Caption.Text = string.Format(Caption.Text, _Product.Name);
        CancelButton.NavigateUrl = "~/Admin/Catalog/Browse.aspx?CategoryId=" + PageHelper.GetCategoryId();
        CancelButton1.NavigateUrl = "~/Admin/Catalog/Browse.aspx?CategoryId=" + PageHelper.GetCategoryId();
        PageHelper.SetHtmlEditor(Description, DescriptionHtml);
        PageHelper.SetHtmlEditor(ExtendedDescription, ExtendedDescriptionHtml);        
        PageHelper.SetPageDefaultButton(Page, SaveButton);
        BindManufacturers();
        BindDisplayPage();
        BindThemes();
    }

    protected void UploadButton_Click(object sender, EventArgs e)
    {
        if (MSDS.HasFile)
        {
            string theFileName = Path.Combine(Server.MapPath("~/PDF/"), MSDS.FileName);
            if (File.Exists(theFileName))
            {
                File.Delete(theFileName);
            }
            MSDS.SaveAs(theFileName);
        }
    }
...

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Adding PDF Brochures, Informationals, etc.

Post by david-ebt » Wed Jan 04, 2012 6:18 pm

It may be mapping the path to a subfolder of the ADMIN directory.

Try changing the MapPath line to this:

Code: Select all

string theFileName = Path.Combine(Server.MapPath("/PDF/"), MSDS.FileName);
This assumes you have a folder at the root of the site called PDF (same level as BIN, APP_CODE, etc).
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Adding PDF Brochures, Informationals, etc.

Post by david-ebt » Wed Jan 04, 2012 7:12 pm

Also take a look at this forum post for a more complete description of the changes to support an upload file in the product admin edit page.

viewtopic.php?f=47&t=12056
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

RKS_213
Lieutenant (LT)
Lieutenant (LT)
Posts: 69
Joined: Mon Dec 26, 2011 2:48 pm

Re: Adding PDF Brochures, Informationals, etc.

Post by RKS_213 » Thu Jan 05, 2012 4:28 pm

Thanks, David. For everyone else needing this in the future, that thread posted helped a great deal.

Post Reply