Search

Ok. Bit of a noob question here but hoping someone can help me out as I’m making spaghetti out of my brain on this.

Here is the XML that I am out putting:

<projects>
    <section id="10" handle="projects">Projects</section>
        <entry id="49">
            <project-title handle="good-and-fair-project">Good &amp; Fair Project</project-title>
            <thumbnail items="1">
                <item>
                    <thumbnail size="52 kb" path="/uploads" type="image/png">
                        <filename>gfpthumb-1264061453.png</filename>
                        <meta creation="2010-01-21T02:10:53-06:00" width="150" height="200" />
                    </thumbnail>
                    <description word-count="4">Good And Fair Project</description>
                </item>
            </thumbnail>
            <manage-images>Yes</manage-images>
            <body word-count="287" mode="formatted"><p>blah, blah, blah</p>
            </body>
            <date time="16:22" weekday="3">2010-01-20</date>
            <categories>
                <item handle="branding" id="39">Branding</item>
                <item handle="print" id="37">Print</item>
                <item handle="website" id="36">Website</item>
            </categories>
            <discipline>
                <item handle="branding">Branding</item>
            </discipline>
            <project-images items="2">
                <item>
                    <image size="97 kb" path="/uploads" type="image/jpeg">
                        <filename>gfp-big1-1264059455.jpg</filename>
                        <meta creation="2010-01-21T01:37:34-06:00" width="790" height="350" />
                    </image>
                    <description word-count="6">Good And Fair Project Logo Treatment</description>
                </item>
                <item>
                    <image size="169 kb" path="/uploads" type="image/jpeg">
                        <filename>gfp-big2-1264542295.jpg</filename>
                        <meta creation="2010-01-26T15:44:55-06:00" width="790" height="350" />
                    </image>
                    <description word-count="3">Big Test 2</description>
                </item>
            </project-images>
            <excerpt word-count="8" mode="formatted"><p>Good <span class="amp">&amp;</span> Fair. What better way to blah, blah,&#160;blah. </p></excerpt>
        </entry>
</projects>

Here is my utility (get-project.xsl):

<xsl:template match="entry" mode="home">
    <div class="project grid_4">    
        <xsl:call-template name="get-thumbnail">
            <xsl:with-param name="thumbnail-entry" select="thumbnail/item"/>                    
        </xsl:call-template>
        <h3><a href="{$root}/projects/{project-title/@handle}"><xsl:value-of select="project-title"/></a></h3>
        <xsl:apply-templates match="excerpt" mode="truncate">
            <xsl:param name="limit" select="100"/>
            <xsl:param name="suffix" select="'&#8594;'"/>
        </xsl:apply-templates>
        <p>
            <xsl:for-each select="discipline/item">
                <a class="tags" href="{$root}/discipline/{@handle}"><xsl:value-of select="."/></a>
                <xsl:if test="position() != last()">+</xsl:if>
            </xsl:for-each>
        </p>
        <p class="date">
            <span><xsl:call-template name="format-date">
                <xsl:with-param name="date" select="date"/>
                <xsl:with-param name="format" select="'d m Y'"/>
            </xsl:call-template></span>
        </p>

        <!--need help -->
        <p class"quicklook">
            <a href="location of first image in the series from PROJECT-IMAGES" rel="prettyPhoto[needs to be PROJECT HANDLE]">QuickLook</a>
        </p>
        <div class="hidden">
            <!--needs to pull all images from entry i.e. as follows-->
            <img src="first image in the series" rel="prettyPhoto[needs to be PROJECT HANDLE]">
            <img src="first image in the series" rel="prettyPhoto[needs to be PROJECT HANDLE]">
            etc, etc...
        </div>
        <!--end need help-->

    </div>          
</xsl:template>

Let me know if that’s not clear enough. Its obviously not to me. ;) I can post more or help out any way possible. Thanks if anyone takes a look at this.

Hi dallaspeters,

I believe this is what you are looking for, it’s crude, but it should work:

<a href="{thumbnail/item[1]/@path}/{thumbnail/item[1]/filename}" rel="prettyPhoto[{project-title@handle}]">QuickLook</a>
...
<img src="{thumbnail/item[1]/@path}/{thumbnail/item[1]/filename}" rel="prettyPhoto[{project-title@handle}]">

When you need to reference something into an attribute, there are a few methods of doing this. The first is the example I’ve put above (which you kind of already used for your H3 tags) - essentially you put your xpath statement into curly braces {} letting xslt know you want it to execute the xpath call.

When you start to get to a point where you need to call the same thing over again you may want to store that call in a param or a variable and then call it into the curly braces. A typical example is {$root} which you’ve probably seen a few times now.

Lastly, if you need to manipulate multiple attributes you may want to consider combining the above methods into something like this:

<img>
<xsl:variable name="pathtoimage" select="thumbnail/item[1]/@path"/>
<xsl:attribute name="src"><xsl:value-of select="$pathtoimage"/><xsl:value-of select="thumbnail/item[1]/filename"/></xsl:attribute>
</img>

I hope this was what you were looking for.

I’ve also used this prettyPhoto on a Symphony project, so I know what you’re aiming for http://www.amandadredge.co.uk

Thanks for getting back. Not sure I’m doing it right. (though rather than ‘thumbnail’ I’m after ‘project-images’)

I have:

<p class="quicklook">
  <a class="magnify" href="{project-images/item[1]/@path}/{project-images/item[1]/filename}" rel="prettyPhoto">QuickLook</a>
</p>

Which is outputting this:

<a rel="prettyPhoto" href="/" class="magnify">QuickLook</a>

And then when I try to use the rel="prettyPhoto[{project-title@handle}]" it gives me:

  • XSLTProcessor::importStylesheet(): Invalid expression
  • XSLTProcessor::importStylesheet(): Attribute ‘rel’: Failed to compile the expression ‘project-title@handle’ in the AVT.
  • XSLTProcessor::transformToXml(): No stylesheet associated to this object

Sure I’m doing something wrong.

that first output didn’t take in the forum.

<a rel="prettyPhoto" href="/" class="magnify">QuickLook</a>

My first guess would be

{project-title/@handle}
<a class="magnify" href="{$root}/workspace/{project-images/item[1]/image/@path}/{project-images/item[1]/image/filename}" rel="prettyPhoto[{project-title/@handle}]">Quicklook</a>

worked, but seems like a really clunky way of doing it eh?

What ended up working:

<p class="quicklook">
  <a class="magnify" href="workspace{project-images/item[position() = 1]/image/@path}/{project-images/item[position() = 1]/image/filename}" rel="prettyPhoto[{project-title/@handle}]">Quicklook</a>
  </p>

  <div class="hidden">
    <xsl:for-each select="project-images/item[position() &gt; 1]">
    <a>
      <xsl:attribute name="href">workspace/uploads/<xsl:value-of select="image/filename"/>
      </xsl:attribute>
      <xsl:attribute name="rel">prettyPhoto[<xsl:value-of select="../../project-title/@handle"/>]</xsl:attribute>
      <img>
        <xsl:attribute name="src">workspace/uploads/<xsl:value-of select="image/filename"/>
      </xsl:attribute>
      </img>
      </a>
    </xsl:for-each>
  </div>

Feels pretty sloppy. For some reason I have to put workspace in there. Not sure if my get-images.xsl is messing with the urls of my images. I’m also using Mediathek.

you can tighten up the xsl with concat:

<a>
    <xsl:attribute name="href" select="concat($workspace, '/uploads/', image/filename)" />
    <xsl:attribute name="rel" select="concat('prettyPhoto[',../../project-title/@handle, ']')" />
    <img>
        <xsl:attribute name="src" select="concat($workspace, '/uploads/', image/filename)" />
    </img>
</a>

another approach is doing it all inline:

<a href="{$workspace}/uploads/{image/filename}" rel="prettyPhoto[{../../project-title/@handle}]>
    <img src="{$workspace}/uploads/{image/filename}" />
</a>

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