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 5 of 5

Thread: ML 7 - Getting XML of Topics

  1. #1
    JoshuaChr is offline Junior Member
    Join Date
    Apr 2008
    Location
    Chicago, IL
    Posts
    9

    Default ML 7 - Getting XML of Topics

    Is there an easy way to get the XML list of topics that are published (and only topics) to use in a menu control?

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

    Default

    If you are trying to use this in an xmlpackage, just use the following query in the xmlpackage file
    Code:
    <query name="Topics" rowElementName="Topic">
      <sql>
        <![CDATA[
          select * from dbo.Topic where deleted=0
        ]]>
      </sql>
    </query>
    This will return all topics in xml format for use in the xmlpackage, eg.
    Code:
    <Topics>
      <Topic>
        <Name>TopicName</Name>
        <Title>TopicTitle</Title>
        ...
        ...
      </Topic>
      <Topic>
        <Name>TopicName2</Name>
        <Title>TopicTitle2</Title>
        ...
        ...
      </Topic>
      <Topic>
        <Name>TopicName3</Name>
        <Title>TopicTitle3</Title>
        ...
        ...
      </Topic>
      <Topic>
        <Name>TopicName4</Name>
        <Title>TopicTitle4</Title>
        ...
        ...
      </Topic>
    </Topics>
    If you set debug="true" in the package node you can see the xml structure on the page when you browse to a page using that xmlpackage. Please elaborate on where/how you're trying to do this (from a codebehind file, in the skin, etc...) if you are looking for something different.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  3. #3
    JoshuaChr is offline Junior Member
    Join Date
    Apr 2008
    Location
    Chicago, IL
    Posts
    9

    Default

    Thank you. That was a good start. I am having a bit of trouble though. I apologize, our company does not do many eCommerce projects and this is our first and only with your software. It's also been many months since I was last in this project.

    What I'd like, is something like the TopMenu config that just spits out a HTML list of all of pages. I was playing around with a copy of the TopMenu but I am not familar enough with how all the data is getting pulled and XMLPackages to really know exactly what I am doing.

    Would you happen to already have something like this already?

  4. #4
    JoshuaChr is offline Junior Member
    Join Date
    Apr 2008
    Location
    Chicago, IL
    Posts
    9

    Default

    Actually, better yet, this is what I have so far. What I am getting is that only the first item from the results is showing. Also, I do not know what to look for from the result set to do a 'selected' class on the current item.

    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Topic Data As Xml" debug="false" allowengine="true" includeentityhelper="false">
    	<query name="Topics" rowElementName="Topic">
    		<sql>
    			<![CDATA[
    				select * from dbo.Topic where deleted=0 AND ShowInSiteMap=1 AND Name LIKE 'gh_%'
                ]]>
    		</sql>
    	</query>
    
    	<PackageTransform>
    		<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
    			<xsl:output method="xml" omit-xml-declaration="no" />
    			<xsl:param name="PageTitle">
    				<xsl:for-each select="/">
    					<xsl:value-of select="root/Topics/Topic/Title"/>
    				</xsl:for-each>
    			</xsl:param>
    			<xsl:param name="PageName">
    				<xsl:for-each select="/">
    					<xsl:value-of select="root/Topics/Topic/Name"/>
    				</xsl:for-each>
    			</xsl:param>
    			<xsl:template match="/">
    				<ul>
    					<xsl:for-each select="/">
    						<li>
    							<a href="{concat('t-',$PageName,'.aspx')}">
    								<xsl:if test="">
    									<xsl:attribute name="class">Selected</xsl:attribute>
    								</xsl:if>
    								<xsl:value-of select="$PageTitle"/>
    							</a>
    						</li>
    					</xsl:for-each>
    				</ul>
    			</xsl:template>
    		</xsl:stylesheet>
    	</PackageTransform>
    </package>

  5. #5
    data77 is offline Member
    Join Date
    Oct 2010
    Posts
    75

    Default

    Do something like this
    it will work for you
    <package version="2.1" displayname="Departments" debug="false" allowengine="true" includeentityhelper="false">

    <query name="Topics" rowElementName="Topic">
    <sql>
    <![CDATA[
    select * from dbo.Topic where deleted=0 AND ShowInSiteMap=1
    ]]>
    </sql>
    </query>

    <PackageTransform>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
    <xslutput method="xml" omit-xml-declaration="no" />


    <xsl:template match="/">
    <xsl:for-each select="root/Topics/Topic">
    <xsl:sort select="DisplayOrder"/>
    <xsl:sort select="Name"/>

    <xsl:element name="li">
    <xsl:element name="a">
    <xsl:attribute name="href">
    <xsl:value-of select="concat('t-',Name,'',SEName,'.aspx')"/>
    </xsl:attribute>
    <xsl:value-of select="aspdnsf:GetMLValue(Title)"/>
    </xsl:element>

    </xsl:element>

    </xsl:for-each>



    </xsl:template>


    </xsl:stylesheet>
    </PackageTransform>
    </package>
    Eat my code!
    Multistore V 9 sp1
    Best Hosting for your storefront Business in 2011

    http://fasoservice.com
    world wide directory submission
    http://Nanalist.com
    Burkina24 Media news in Burkina Faso
    http://burkina24.com