Search

I apologize before-hand if this is simple, or maybe asked/answered somewhere already.. I've never worked this deep in Symphony before, and I can't seem to find a solution.

I'll try and explain a little better.. Basically, I'm creating something similar to a discussion forum, using the new members extension.. I have a section for comments with a select box link field to reference the member who posted the comment..

I can't seem to get the select box link to include more than just the username. I'd like it to also pull the email address/hash (so I can use gravatar), and I have an optional "avatar" file field that I'd like to associate with as well.. Having them all grouped inside my created-by xml.

I figured that I just had to highlight all the fields I want in the select box link field, but that doesn't seem to be the case.

Is there a way to do this at all? Does it make more sense to create a separate select box link for each field I want pulled in, or is there some other preferred solution to what I'm shooting for here?

Thanks ahead of time.

in the past, i've always had to create a minimal datasource with all of the users in order to cross-reference the select box link's id with the user's id in the user datasource.

if there were an easier way, i would also love to hear about it.

The data shown in the XML is the field that populates the dropdown in the backend. To get more data you should use "data source chaining". Select the SBL field in the Parameter Output settings in your existing data source. This will add the IDs of the related entries into the param pool. Now create a second data source filtering from the section that populates the SBL, and filter the System ID by this new parameter. You'll then be able to cross reference the entries in XSLT.

Alright, I definitely follow, but I'm still a little unsure on how to use the data I have now. My initial ds contains the following xml (snipped):

<discussions-comments>
    <section id="2" handle="comments">Comments</section>
    <entry id="20" attachments="0" likes="0">
        <comment mode="formatted"><p>This is the first post in this discussion..</p>
        </comment>
        <created-date time="00:15" weekday="2">2011-04-05</created-date>
        <modified-date time="00:15" weekday="2">2011-04-05</modified-date>
        <created-by>
            <item id="1" handle="xxxxxx" section-handle="members" section-name="Members">xxxxxx</item>
        </created-by>
    </entry>
</discussions-comments>

I set the created-by field as the paramter output for this ds, which puts the following list of items in my params, as expected:

<ds-discussions-comments>
    <item handle="1">1</item>
    <item handle="1">1</item>
    <item handle="4">4</item>
    <item handle="1">1</item>
    <item handle="1">1</item>
    <item handle="1">1</item>
    <item handle="1">1</item>
    <item handle="15">15</item>
    <item handle="16">16</item>
    <item handle="1">1</item>
    <item handle="24">24</item>
    <item handle="15">15</item>
    <item handle="4">4</item>
</ds-discussions-comments>

Which is correct.. this is actually the correct amount of comment entries, and it seems to be in order with the correct id's..

And now my new ds, filtered by the param:

<discussions-commenters>
    <section id="4" handle="members">Members</section>
    <entry id="24">
        <email-address hash="xxxxxx">xxxxxx@xxxxxx.com</email-address>
    </entry>
    <entry id="16" />
    <entry id="15">
        <avatar size="18 KB" path="/uploads/avatars" type="image/jpeg">
            <filename>awesome-gorilla-battle.jpg</filename>
            <meta creation="2011-04-04T14:04:10-06:00" width="400" height="302" />
        </avatar>
    </entry>
    <entry id="14" />
    <entry id="4">
        <email-address hash="xxxxxx">xxxxxx@xxxxxx.com</email-address>
    </entry>
    <entry id="1">
        <email-address hash="xxxxxx">xxxxxx@xxxxxx.com</email-address>
    </entry>
</discussions-commenters>

Which is great.. it's doing what it should be, right? Only pulling in the users who have actually posted a comment to this particular discussion..

I guess I'm just stuck on what to do to reference these two in my xslt.. Is the point of the parameters strictly for pulling only those who posted a comment, and now I just use the two ds's to reference each other, and not have to really deal with the params at all? Is there possibly an example of ds chaining, perhaps in an ensemble that you know of?

Sorry, I'm just about waste deep in water that I should probably only be dipping my toes in, so I am getting confused a little too easy. I appreciate you pointing me in the right direction though.

Is the point of the parameters strictly for pulling only those who posted a comment, and now I just use the two ds's to reference each other, and not have to really deal with the params at all?

i understand what nick is saying now - i haven't used ds output parameters to output multiple entries before, so i'm just taking a blind stab at it here (plus it's almost 2 am and i'm only operating on sleep deprivation and cheap american beer here). it should at least point you in the right direction. here is an example (without relevant aesthetic markup):

<xsl:for-each select="discussions-comments/entry">
    <xsl:copy-of select="comment/*" />

    <xsl:variable name="created-by" select="created-by/item/@id" />
    posted by: <xsl:value-of select="discussions-commenters/entry[@id=$created-by]/email-address" />
</xsl:for-each>

in this instance, i created a variable containing the current id of the comment's author and then use it to grab the necessary entry from your discussions-commenters data source. i remember reading something a while back from nils about a better way to do this that doesn't involve variables, but it doesn't come to me at the moment.

i remember reading something a while back from nils about a better way to do this that doesn't involve variables, but it doesn't come to me at the moment.

You can use the current() XPath function in the predicate to switch to the "outer" context.

posted by: <xsl:value-of select="discussions-commenters/entry[@id = current()/created-by/item/@id]/email-address" />

Thanks guys,

These are both much cleaner solutions than what I came up with, which was pretty much a combination of the two. I had set a variable, and was also using current(), then my xslt was slightly different / messier.

I think I get the gist of how chaining works though, and I'll probably use it all over the place now.

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