How to add code to head of specific page

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

How to add code to head of specific page

Post by Brewhaus » Fri Oct 17, 2014 12:02 pm

We are trying to add some code from FB for a campaign that our SM person is running, but it requires us to put some code in the HEAD section of the final checkout page (Payment.ascx). We can easily add the code inside of a HEAD section, but that will give two head tags, which is probably sloppy code. Is there a way to add something to the head section on just this page?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: How to add code to head of specific page

Post by jguengerich » Fri Oct 17, 2014 1:24 pm

There may be a much easier way to accomplish this than what I have below, so if there is hopefully someone else will answer.

Caution: I did a very simple test and the following seemed to work, but I am still on R5. This assumes that Payment.aspx has a master page of /Layouts/Fixed/Checkout.master, which in turn has a master page of /Layouts/Fixed/Base.master, which already has this:

Code: Select all

<asp:ContentPlaceHolder ID="HtmlHeader" runat="server">
</asp:ContentPlaceHolder>
in it.

The Layouts/Fixed/Base.master file has a content place holder for the html header called "HtmlHeader". In the Layouts/Fixed/Checkout.master file, you could add a content section that refers to that, and provides another content place holder that could be used by Payment.aspx.

So checkout.master would have something like this right after the <%@.... lines at the top:

Code: Select all

<asp:Content ID="HtmlHeader2" runat="server" ContentPlaceHolderID="HtmlHeader">
    <asp:ContentPlaceHolder ID="HtmlHeader3" runat="server"></asp:ContentPlaceHolder>
</asp:Content>
Payment.aspx would have something like this right after the <%@.... lines at the top:

Code: Select all

<asp:Content ID="MyCustomHtmlHeadStuff" runat="server" ContentPlaceHolderID="HtmlHeader3">
<%-- anything in this content area will be inserted in the HTML <head> element --%>
</asp:Content>
YMMV :)
Jay

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: How to add code to head of specific page

Post by Brewhaus » Sat Oct 18, 2014 9:06 am

That appears to work (and I am on R8, so I assume that it will work for anyone on a Gold version). Thanks for the help! :-)
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

Post Reply