Search

Hi

I'm new to the forums here but have been using Symphony for a number of projects and love it.

I am stuck with a problem with the current project I am working on when trying to output images that are stored using subsection manager.

Here is my xslt:

Last Update:

Images:

Content:

<xsl:template match="project-detail/entry/images/item" >
   <li>
      <img src="{$root}/image/1/80/80{image/@path}/{image/filename}"/>
   </li>
</xsl:template>

And my XML:

<project-detail>
   <section id="5" handle="projects">Projects</section>
   <entry id="23">
      <title handle="test-project-1">Test Project 1</title>
      <content mode="formatted"><p>This is the description of project 1</p>
      </content>
    <date time="12:54" weekday="4">2011-08-18</date>
    <images items="2">
    <item id="32">
      <image size="6 KB" path="/images" type="image/gif">
        <filename>consulting_small.gif</filename>
       <meta creation="2011-08-18T12:18:46+00:00" width="120" height="104" />
     </image>
      <caption handle="test-image-1">test image 1</caption>
     </item>
     <item id="33">
       <image size="7 KB" path="/images" type="image/gif">
        <filename>intelligence_small.gif</filename>
       <meta creation="2011-08-18T12:20:26+00:00" width="120" height="104" />
     </image>
      <caption handle="test-image-2">test image 2</caption>
     </item>
    </images>
   </entry>
</project-detail>

But my HTML output looks like this:

<h2>Test Project 1</h2>

  <p>Last Update: 2011-08-18</p>
  <p>Images:</p>
  <ul>
        Test Project 1
        This is the description of project 1

        2011-08-18

            <li><img src="http://www.atlanticorp.dreamhosters.com/image/1/80/80/images/consulting_small.gif" /></li>
            <li><img src="http://www.atlanticorp.dreamhosters.com/image/1/80/80/images/intelligence_small.gif" /></li>

    </ul>
  <p>Content:</p>

  <p>This is the description of project 1</p>

In other words when it gets to applying the template to ouput the images it first outputs the raw xml before the correctly formatted images.

Has anyone got any suugestions?

Thanks in advance, Dave

oops - top part of xslt should read:

<xsl:template match="project-detail/entry">
  <h2><xsl:value-of select="title"/></h2>
  <p>Last Update: <xsl:value-of select="date"/></p>
  <p>Images:</p>
  <ul>
    <xsl:apply-templates match="images/item"/>
  </ul>
  <p>Content:</p>
  <xsl:copy-of select="content/*"/>
</xsl:template>

Hi Dave, my guess is that this has something to do with the XSLT 'default' template rules. This basically outputs the text when no other template matches (hope I explain this properly).

I cannot see how this works here, though, since your /project/entry is matched, as is your /image in there...

woops I see it now. Your xsl:apply-templates has a match attribute where it should be a select I believe.

Try: <xsl:apply-templates select="images/item"/>

Cheers David! Thats fixed it.

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