Search

I thought I understood how to chain datasources but my latest attempt has me questioning that.

I have a section Projects with a Select Box Link field to a second section Products (I want to be able to select multiples but one thing at a time here...). I output the $ds-projects.project_products from the projects data source, then I filter the Project Products data source on System ID equals {$ds-projects.project_products} - pulled from the list I'm given so no typos.

My debug XML on the page shows:

<ds-projects.project_products>
    <item handle="12">12</item>
</ds-projects.project_products>

in my page parameters.

But my <project_products> data source output is just all of my products as though there was no filter at all:

<project-products>
    <section id="8" handle="products">Products</section>
    <entry id="12">
        <page_title handle="product-1">Product 1</page_title>
        <url_handle handle="dothtml">dot.html</url_handle>
    </entry>
    <entry id="15">
        <page_title handle="product-2">Product 2</page_title>
        <url_handle handle="dothtml">dot.html</url_handle>
    </entry>
    <entry id="14">
        <page_title handle="product-3">Product 3</page_title>
        <url_handle handle="dothtml">dot.html</url_handle>
    </entry>
</project-products>

Everything looks just right until I get the full list of products. Does anyone see what I'm missing here?

Sorry if you are sick and tired of seeing my face around here, I feel like I've hit this forum like a ton of bricks. Thanks for reading anyway.

{$ds-products.system-id}

should do what you want.

your output shoould look like:

<projects>
<entry>
<products>
<item />
<item />
</products>
</entry>
</projects>

or the other way round. sry tired..

Have you tried adding $ds-projects.project_products as required url parameter in the second datasource?

Not sure if thats the problem, but thats generally what I do when I chain datasources to ensure the second datasource doesn't run unless there is some related entries from the first datasource.

@moma Thanks for your reply, but I don't have access to {$ds-products.system-id} from inside my Projects datasource, I only have the contents of the Select Box Link which gives me $ds-projects.project_products (since the name of that field is Project Products).

As for the given output, mine would look like that if I were including the Project Products field in my output, but I'm not because I need more information than it gives me. I am trying to output the Product System Id so I can chain the Product datasource with it.

I believe the output I want will look like:

<projects>
    <entry>...</entry>
</projects>
<project-products>
    <entry id="the-id-I-am-filtering-on">...</entry>
</project-products>

@davecoggins I did try adding the required parameter as you suggested, but I get no results then. I thought perhaps this is only applicable to URL parameters, not page parameters?

Thank you both for your responses.

If I understand the situation correctly you have projects that can have many products, correct? I guess the first datasource is to filter a particular project or is it to show all projects?

Assuming you wanted to filter a particular project and show all the related products within that project this is how I would go about it:

  1. Create project datasource and add a filter (e.g. project title) to select the correct project (adding the project title to the required paramter if filtering)
  2. Output $ds-project.system-idon first datasource
  3. Create second datasource for related products. Add a filter for the selectbox link field and using the $ds-project.system-id. I normally add $ds-project.system-id to the required paramter.
  4. Add both datasources to the required page

Hope i've got that right, late at night here and getting tired :)

@davecoggins Thanks for the breakdown. I run into trouble on step 3 - how is this different from just including the output of the Select Box Link in my first datasource?

My goal is to filter out a single Project and show it and all of its related Products. The Projects have the Select Box Link to the Products - Products have no link back. I thought this could be accomplished by outputting the Products' System-ids from the Select Box Link in the Project data source, then adding a second data source (for Products) that filters by the outputted Product System-id, but it is not working for me... I either get all of the Products, or none if I make the id a required parameter. But I know the id is being output because I see it in the debug XML, and I know the output id matches the Product ids because those show too... very confusing.

What you are doing is correct. I'm not sure why it's not working for you.

If you change {$ds-projects.project_products} to 12, do you get

<project-products>
    <section id="8" handle="products">Products</section>
    <entry id="12">
        <page_title handle="product-1">Product 1</page_title>
        <url_handle handle="dothtml">dot.html</url_handle>
    </entry>
</project-products>

I've just recreated what I think you're describing - I thought it easier to make screenshots of all the pages/settings rather than try to describe it all by words. See attachments (they're in the order I'd recommend doing them) and then final one frontend-debug.png showing what should emerge at the end. Hope it helps :)

EDIT: oops, forum changed the upload order, here's the correct order...

  1. sections-product
  2. sections-project
  3. content-product
  4. content-project
  5. ds-project-by-title
  6. ds-products-by-project
  7. pages-project
  8. frontend-debug
Attachments:
frontend-debug.png, pages-project.png, ds-products-by-project.png, ds-project-by-title.png, content-project.png, content-product.png, sections-project.png and sections-product.png

I do get this figured out by the end of this post.

Thank you both for your helpful responses.

@Pat - yes, if I put 12 into the filter instead of {$ds-projects.project_products}, I get the desired result (only product 12 shows) - do you know what could be causing this miscommunication?

@firegoby - you have duplicated my situation exactly, except for your results which are right while mine are wrong... as you can see in the attached screenshots: One of my Project Products data source, showing I am filtering on the information output by the Projects ds, and the other showing that I get all of my products even though the filter is present. What is going on here?

As I wrote this, I found my problem. {$ds-projects.project_products} =/= {$ds-projects.project-products}! This is obvious, I know, but as I mentioned before:

...System ID equals {$ds-projects.project_products} - pulled from the list I'm given so no typos.

Well, there was a typo. The underscore I shared was actually a hyphen and I didn't notice (we all knew it had to be something stupid, huh?). This leads to my next question though, why the heck does the list give me the wrong variable name?! (see wrong-list.jpg) I thought I could trust it... does anyone else have this issue?

Attachments:
wrong-list.jpg, project-products.JPG and debugXML.JPG

Seems like a bug in whatever generates the list.

Personally, I only use dashes, so I haven't experience this problem.

I have no idea why the underscore/hyphen thing is happening, very weird indeed - above my pay grade I'm afraid :) I think you'll need to check with one of the core developers who understand how they generate those names, when underscore vs hyphens are used etc

Glad you got it working in the end!

Looks like a bug to me. Can you file it with the attachments on the Github issue tracker please Sarah? Either Brendan or me will try and look at it asap.

Thanks in advance

Thanks @designermonkey, I added an issue: https://github.com/symphonycms/symphony-2/issues/1817

I hope it is clear enough.

I really want to know where that underscore is coming from. Do your fields actually have underscores in them? If so, why?

The screenshot above, wrong-list.jpg, is actually correct. Those values should have handles, so project-products is right, project_products is wrong.

Brendan, there's a response on the ticket about that.

@sarahkemp I've tried to track this issue down tonight but I've been unable to replicate the Output Parameters from including the name with an _ instead of -.

Section Editor Datasource Editor

With your naming convention, are you also applying that to the handle field in the Section Editor?

Edit: Ah, so if I explicitly change the handle to include underscores, then I can reproduce the issue. Fix to come

Attachments:
Screen Shot 2013-09-17 at 10.20.10 PM.png and Screen Shot 2013-09-17 at 10.20.01 PM.png

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