Search

A newbie but certainly impressed Symphony's user here. Love the flexibility. I need some advice from the experts :)

I have a project, it has an especial category with detailed informaction, more specifically, it is a hotel category; and also have a promo section. Let's say the following:

Hotel category (section) - Name - Description - Availability

Promo item (section) - Title - Description - Hotel (a Select Box Link, populated with the hotels)

What I need to do is to display the promos, and with each one of them the information relative to the hotel they belong to (I need to retrieve that information), for example:

Promo 1 (promo section item) - Promo title - Promo description - Hotel availability (this information is not in the promo, but in the hotel it belongs to)

Thank you, guys. I would really appreciate any advice on this.

M

Are you using Select box or Select Box Link? If you use the later, you could grab the ID of the hotel entry in the output XML using chaining methods.

Yes, I'm using the Select Box Link for the hotel in the promotion section...

In these situations a technique called data source chaining may help you out. Filtering The hotel data source from within the promo data source by using an output parameter such as $ds-promo.hotel (list of available output paramaterscan see selected bottom left of every data source page in the symphony back end)

Then in the hotel data source add a new filter that uses Hotel: System ID and use something like {$ds-promo.hotel} as the filter value (the param use will depend on how you are using the select box link and what section it is contained within.

Also if the Hotel data source is used for other purposes on the page, you may need a specific data source for filtering with the promo...

I did just what you said in the previous comments, several times, but nothing seems to work.

The XML output doesn't contain nothing more than the hotel id graved from the promo datasource. I know, this is the ID I need and everything. But what am I supposed to do with it? I don't see any data from the hotel in the promos page.

In resume, right now I have the following:

  1. Promotions data source: this gets the promotions from the promotions section. This also has $ds-promotions.hotel output parameter selected.
  2. Hotels data source: this gets the hotels from the hotels section. This also has a System ID result filter with $ds-promotions.hotel in it's field.

Nothing "extra" is showing off in the promotions XML, just the information of the promotion itself. Also, the available XML output elements (included elements) hasn't added any extra fields from the hotel, is this supposed to change and add the hotel fields?

Thank you, M

If you've got the XML output showing the data from the two separate data sources, then it's worked and it's now down to you to combine the various results via IDs using XSLT.

Symphony itself doesn't combine the XML output from two different data sources, but if the relationship is set up using the Selectbox Link field then it will give you the information you need to work with the data.

Perhaps you could post a few sample entries from each data source, and let us know if you need help with the XSLT.

No. It is not showing the hotel information. The nodes my XML is displaying right now are only the ones from the promotions data source.

Well, it's getting really hard to get this to work. The thing is I don't want to get back to Drupal, but my deadline doesn't give me that much of time to deal with this anymore. Thank you, guys, for helping!

M

Have you selected which fields youd like to include in the xml? Select which fields you want to output in bottom right of each datasource edit page in symphony backend.

Yes, there are not any extra fields other than the relatives to the promotion section.

Could you post a pastie.org of your XML output? All the data you need should be in the XML if the filters are correct.

Have you also selected both data sources in the Page's data source field?

Perhaps I had to go the page and select "Promotions" and "Hotels" in the "Data sources" section? It is displaying the hotels based on the $ds-hotel parameter selected in the promotion (section item).

Here, take a look at the screenshots. Here is the pastie: http://pastie.org/8417400

Also, now this is a question regarding xPath and XSLT: In my case, based on my XML output, how can I select the hotel from /data/hotels based on the ID from /data/promotions/entry/hotel/item ?

or maybe with a choose...

Attachments:
ds-promotions.png and ds-hotels.png

Perhaps I had to go the page and select "Promotions" and "Hotels" in the "Data sources" section?

Yes, Symphony will not automatically add a data source to a page.

Also, now this is a question regarding xPath and XSLT: In my case, based on my XML output, how can I select the hotel from /data/hotels based on the ID from /data/promotions/entry/hotel/item ?

This is not tested, but hopefully shows you one approach using an XSLT key:

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

    <xsl:key name="hotels-by-id" match="/data/hotels/entry" use="@id"/>

    <xsl:template match="/data">
        <h1>Promotions</h1>
        <xsl:apply-templates select="promotions/entry"/>
    </xsl:template>

    <xsl:template match="/data/promotions/entry">
        <h2><xsl:value-of select="title/@en"></h2>
        <xsl:apply-templates select="key('hotels-by-id', hotel/item/@id)"/>
    </xsl:template>

    <xsl:template match="/data/hotels/entry">
        <p>Hotel name: <xsl:value-of select="name"></p>
        <p>Hotel environment: <xsl:value-of select="environment/item"></p>
        <p>Hotel location: <xsl:value-of select="location/item"></p>
    </xsl:template>

<xsl:stylesheet>

Thanks for replying. I will read your approach in detail.

David and Moonoo2, thank you so much for your guidance. That worked like a charm.

I'm very enthusiastic about how Symphony handles the data and the flexibility it gives to the developer, I started using it two days ago, and I have the back-end of my project already finished.

I'm actually thinking to contribute with a extension I have in mind. :)

Thanks!

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