I've just started developing with Umbraco recently..I've been having a hard time getting my XSLT macro to work correctly.
What I need it to do is request the query string 'id' (which it does) and store that in a variable, and then use that variable to pull the appropriate record from the database.
<xsl:variable name="listing" select="sqlGetListings:GetDataSet('umbracoDbDSN', 'select Name from dbo.Directory where Id = {$listingId}', 'Directory')//Directory"/>
<li> <xsl:value-of select="$listing"/> </li>
</xsl:template>
It seems like the {$listingId} does not work correctly inside the GetDataSet method. I've tried just displaying the listingId variable to make sure it was pulling the query string and it was, also tried inputting a static number into the sql statement and that would work. Any guidance would be appreciated!
<xsl:variable name="listing" select="sqlGetListings:GetDataSet('umbracoDbDSN', concat('select Name from dbo.Directory where Id =', $listingId), 'Directory')//Directory"/>
Using xsl:variable in sql statement
I've just started developing with Umbraco recently..I've been having a hard time getting my XSLT macro to work correctly.
What I need it to do is request the query string 'id' (which it does) and store that in a variable, and then use that variable to pull the appropriate record from the database.
<xsl:template match="/">
<xsl:variable name="listingId" select="umbraco.library:RequestQueryString('id')"/>
<xsl:variable name="listing" select="sqlGetListings:GetDataSet('umbracoDbDSN', 'select Name from dbo.Directory where Id = {$listingId}', 'Directory')//Directory"/>
<li>
<xsl:value-of select="$listing"/>
</li>
</xsl:template>
It seems like the {$listingId} does not work correctly inside the GetDataSet method. I've tried just displaying the listingId variable to make sure it was pulling the query string and it was, also tried inputting a static number into the sql statement and that would work. Any guidance would be appreciated!
I figured it out...
I tried using concat() before but i added extra ' so it didn't work.
For anyone who runs into similar trouble, this is the correct code
<xsl:template match="/">
<xsl:variable name="listingId" select="umbraco.library:RequestQueryString('id')"/>
<xsl:variable name="listing" select="sqlGetListings:GetDataSet('umbracoDbDSN', concat('select Name from dbo.Directory where Id =', $listingId), 'Directory')//Directory"/>
<li>
<xsl:value-of select="$listing"/>
</li>
</xsl:template>
is working on a reply...