Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: (!SECTION_TITLE!) in XMLPackage

  1. #1
    BloomerBeak is offline Member
    Join Date
    Oct 2007
    Location
    Davao City
    Posts
    76

    Question (!SECTION_TITLE!) in XMLPackage

    Good day everyone!

    I just want to ask if there's a way to put a breadcrumb using the XMLPackage?
    I tried putting
    Code:
    <div id="breadcrumb">(!SECTION_TITLE!)</div>
    on my XMLPackage but it won't display anything.

    I also just put (!SECTION_TITLE!) only, hoping it will work as my
    Code:
    <img src="skins/skin_(!SKINID!)/images/saleTag.png" alt="" id="saleTag" />
    worked on the XMLPackage, but it did not.

    Can someone help me? thanks.
    ***Melay***
    Web Developer
    Philippines

  2. #2
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    The (!SECTION_TITLE!) token does not fire in Parser like the other tokens...it's only parsed when the breadcrumb exists in the skin itself (the token gets replaced in the App_Code/SkinBase.cs(.vb) file). What you would need to do for this to display in an xmlpackage is create a custom extension function (this prevents you from needing to modify the core logic and recompile). Then retrieve the page from the HTTPContext, cast it SkinBase, and retrieve the SectionTitle property. Here's the full code (as written in version 8.0.1.2):

    App_Code/CustomExtensions.cs
    Code:
    using System.Web;
    using System.Web.UI;
    using AspDotNetStorefrontCore;
    using System.Collections.Generic;
    using AspDotNetStorefront;
    
    public class CustomExtensions : XSLTExtensionBase
    {
        #region Constructor
    
        /// <summary>
        /// CustomExtensions Constructor
        /// </summary>
        public CustomExtensions()
            : this(null, 1, null)
        {
        }
    
        public CustomExtensions(Customer cust, int SkinID, Dictionary<string, EntityHelper> EntityHelpers)
            : base(cust, SkinID)
        {
        }
    
        #endregion
    
        public string GetSectionTitle()
        {
            Page p = HttpContext.Current.Handler as Page;
    
            return (p as SkinBase).SectionTitle;
        }
    }
    web.config (new code in red)
    Code:
    <xsltobjects defaultExtension="">
        <extensions>
            <clear />
            <add name="receipt" namespace="urn:receipt" type="ReceiptXsltExtension, app_code"></add>
            <add name="custom" namespace="urn:custom" type="CustomExtensions, app_code"></add>
    	</extensions>
    </xsltobjects>
    Your xmlpackage where you need to use your custom extension functions
    Code:
    ...
    ...
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" xmlns:custom="urn:custom" exclude-result-prefixes="aspdnsf custom" >
    ...
    ...
    <xsl:value-of select="custom:GetSectionTitle()" disable-output-escaping="yes"/>
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  3. #3
    BloomerBeak is offline Member
    Join Date
    Oct 2007
    Location
    Davao City
    Posts
    76

    Default

    Hi Boss George,

    Thank you very much. This really works!

    I already have a custom extension function, but I don't know how to retrieve the Section Titles. Your solution works perfectly and just what I really need.

    Thank you again.
    Last edited by BloomerBeak; 01-23-2010 at 07:42 AM.
    ***Melay***
    Web Developer
    Philippines

  4. #4
    valentim is offline Senior Member
    Join Date
    Apr 2006
    Posts
    192

    Default

    Great tip George - thank you! Why not just pop this in XSLTExtensionBase.cs next release.
    Matthew
    Aydus Consulting
    Strategy+Development+Design=The Aydus Difference

  5. #5
    shanthsp2002 is offline Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Default HI I am using the same

    I have used the same method but finally i got some issue in ShowEntity.cs


    in this line

    using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, m_SkinBase.ThisCustomer, m_SkinBase.SkinID, "", RunTimeParms, String.Empty, true))
    {



    Here I am getting exception "XmlLoadException was unhandiled by user code"

    and the error mesage is "Prefix 'custom' is not defined"


    please help me. its urgent

  6. #6
    Ex-Jesse is offline Member
    Join Date
    Mar 2011
    Posts
    30

    Default

    Prefix not defined means you need to add "custom" to your namespace in the package.
    Code:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" xmlns:custom="urn:custom" exclude-result-prefixes="aspdnsf custom">
    George's code is solid... but when you use it in the template and a 404 erupts, you're going to end up with the XmlPackage error spammed about. You'll want to change his function call to something a little friendlier:

    Code:
            public string GetSectionTitle()
        {
            try
            {
                Page p = HttpContext.Current.Handler as Page;
    
                return (p as SkinBase).SectionTitle;
            }
            catch(Exception x)
            {
                HttpContext.Current.Server.ClearError();
                return "The Twilight Zone";
            }
        }
    That way your breadcrumb can reflect that it's got ABSOLUTELY no idea where you are. In fact, the server doesn't either. And make sure you add using System to the top:
    Code:
    using System;
    using System.Web;
    using System.Web.UI;
    using AspDotNetStorefrontCore;
    using System.Collections.Generic;
    using AspDotNetStorefront;
    I don't get 501 or 401 errors. I only get 404s. And 151s... you know, the errors that happen because you were coding under the influence of Bacardi.

  7. #7
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    When I use this in my xmlpackage that is a mobile xml page, I don't get anything returned. Any suggestions?