Search

I created a content sec and plan on using tat data on all pages. How do I access the xml on all pages?

would it be creating a utility?

looks like I have to make data source nd apply pages to that data source..?

You can use Global Resource Loader to assign a data source to all pages.

nice!

here is the xml code:

<slider-background>
    <section id="11" handle="backround-images">backround images</section>
    <entry id="18">
      <images size="1.46 MB" path="" type="image/jpeg">
        <filename>combines.jpg</filename>
        <meta creation="2013-02-20T15:02:56-07:00" width="2300" height="1533" />
      </images>
    </entry>
    <entry id="17">
      <images size="276 KB" path="" type="image/jpeg">
        <filename>cbp0009340_veer.jpg</filename>
        <meta creation="2013-02-20T15:02:41-07:00" width="640" height="426" />
      </images>
    </entry>
    <entry id="16">
      <images size="261 KB" path="" type="image/jpeg">
        <filename>bxp0004862_veer.jpg</filename>
        <meta creation="2013-02-20T15:02:11-07:00" width="640" height="425" />
      </images>
    </entry>
  </slider-background>

I am trying

  <img src=""{$workspace}/slider-background/entry/images/filename}" />" />  

I know it's wrong, now sure how to make right..

ok I got this

<img src="{$workspace}/{slider-background/entry/images/filename}" />

but it only pulls one, how do I do every? using for each?

heeeel yah, I this to work but wanna double check if correct.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="../utilities/master.xsl"/>
<xsl:import href="../utilities/get-article.xsl"/>
<xsl:import href="../utilities/get-notes.xsl"/>
<xsl:import href="../utilities/get-comments.xsl"/>

<xsl:template match="data">
    <xsl:apply-templates select="homepage-articles/entry"/>
    <xsl:apply-templates select="notes"/>

    <xsl:apply-templates select="slider-background/entry"/>


 <xsl:apply-templates select="slider-background/entry/images/filename"/>

</xsl:template>

<xsl:template match="slider-background/entry">

   <xsl:for-each select=".">
              <p> hello<img src="{$workspace}/{images/filename}" /> </p> 

 </xsl:for-each></xsl:template>

</xsl:stylesheet>

Good stuff. :-)

You should be able to get rid of the for-each as this template is already being applied to every slider-background/entry node.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="../utilities/master.xsl"/>
<xsl:import href="../utilities/get-article.xsl"/>
<xsl:import href="../utilities/get-notes.xsl"/>
<xsl:import href="../utilities/get-comments.xsl"/>

<xsl:template match="/data">

    <xsl:apply-templates select="homepage-articles/entry"/>

    <xsl:apply-templates select="notes"/>

    <xsl:apply-templates select="slider-background/entry"/>

    <-- don't think you need this
    <xsl:apply-templates select="slider-background/entry/images/filename"/>
    -->

</xsl:template>

<xsl:template match="/data/slider-background/entry">

    <p> hello<img src="{$workspace}/{images/filename}" /> </p> 

</xsl:template>

</xsl:stylesheet>

Have a watch of A xsl:apply-templates Tutorial from Allen Chang.

ah ok, so just the template match then?.. thanks!!!!

interesting, I don't have to use a for each if it is a relative node select..

now that I've gotten the images to work, I am trying to figure out applying those to some js variables.....

here is the js code :

&lt;script>
        $.backstretch([
          ***"image path goes here",***

        ], {
            fade: 750,
            duration: 4000
        });
    &lt;/script>

I have tried:

 <xsl:value-of select='entry/images/filename'/>
&lt;script>
        $.backstretch([   
        "<xsl:value-of select='/entry/images/filename'/>",

        ], {
            fade: 750,
            duration: 4000
        });
    &lt;/script>



 </xsl:template>

The images are placed in the workspace folder. and

"<xsl:value-of select='{$workspace}{/entry/images/filename}'/>",

no dice....

Try using <xsl:comment> then your script

then

//
</xsl:comment>

not sure how to do that, i tried but no dice. I think the issue was with the $workspace variable...?

I can't get the worksace path in there correctly

is not correct

truned out to be easier than i thought..

<script> $.backstretch([ " workspace/",

    ], {
        fade: 750,
        duration: 4000
    });
&lt;/script>

check this bad boy out!

&lt;script>
        $.backstretch([
          <xsl:for-each select='entry/images/filename'>
               "workspace/<xsl:value-of select='.'/>",
              </xsl:for-each>
        ], {
            fade: 750,
            duration: 4000
        });
    &lt;/script>

I just blew my own mind

Without seeing your XML, it's difficult to know whether you have used the right context for the xsl:for-each. I was going to suggest that you do something like this:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"
  encoding="UTF-8"
  indent="yes" />

<xsl:param name="workspace" select="'http://getsymphony.com/workspace'" />

<xsl:template match="/data/explore-screenshots">
&lt;script>
  <xsl:text>
  <![CDATA[$.backstretch([
      ]]></xsl:text>

  <xsl:apply-templates select="entry" mode="backstretch" />

  <xsl:text><![CDATA[
    ], {
      fade: 750,
      duration: 4000
  });]]>
</xsl:text>
  &lt;/script>
</xsl:template>

<xsl:template match="entry" mode="backstretch">
<xsl:text>"</xsl:text><xsl:value-of select="concat($workspace, image/@path, '/', image/filename)" /><xsl:text>"</xsl:text>
  <xsl:if test="position() != last()">
    <xsl:text>,
      </xsl:text>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

I suppose the CDATA sections are not entirely necessary, but they would help if your script used any characters that would render the XML invalid (not well-formed). At least this gives you an alternative to using a for-each, introduces the concept of using modes, and demonstrates how to build the URL from the XML created by upload fields.

My apologies. You did supply the XML. So, here is the revised solution (assuming that you didn't just dump your images into the workspace directory).

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details