2 users online. Create an account or sign in to join them.Users

Search

I’m having a problem with a site I’m building and need advice pulling it all together.

The site has a series of events. Each ‘event’ section has other sections linked with a select box link. They are ‘artist’, ‘venue’ and ‘sponsors’.

If I want to pull the data from each one of those linked sections, I have to create a data source for each. For the system to know which ones it needs to filter out, I have to also create a second data source that just produces a parameter for the other data source to filter on.

Right now, for every event page I have to create seven data sources to get all my data:

  • Main entry DS
  • Linked Artist IDs in a param
  • Artist data filtered from previous DS param
  • Linked venue IDs in a param
  • Venue data filtered from previous DS param
  • Linked sponsors IDs in a param
  • Sponsors data filtered from previous DS param

Is there a better way to do this? I think I’m missing something.

Thanks!

In your main event entry DS (I assume here it’s called simply “event,” so adjust the following accordingly), in the grab() function, just below this line:

if($this->_force_empty_result) $result = $this->emptyXMLSet();

Try adding something like the following:

$doc = new SimpleXMLElement($result->generate());

$param_pool['ds-event-artist'] = array();
    foreach($doc->xpath('//artist/item/@id') as $node){
    $param_pool['ds-event-artist'][] = (int)$node;
}

$param_pool['ds-event-venue'] = array();
    foreach($doc->xpath('//venue/item/@id') as $node){
    $param_pool['ds-event-venue'][] = (int)$node;
}

$param_pool['ds-event-sponsors'] = array();
    foreach($doc->xpath('//sponsors/item/@id') as $node){
    $param_pool['ds-event-sponsors'][] = (int)$node;
}

unset($doc);

There’s probably a nice way to condense that, but I don’t have time to think critically right now ;) Anyway, that should create three additional params for you: ds-event-artist, ds-event-venue, and ds-event-sponsors, that you can use to filter the artist, venue, and sponsors DSes. You’ll need to tell those DSes that they depend on the main event DS though. For each, in their __construct function, edit the dependencies from this:

$this->_dependencies = array();

To this:

$this->_dependencies = array('$ds-event');

This will get you from 7 DSes to 4. Obviously, you could simply fully customize the DS to fetch all the data at once, but that’s a bit more involved and then means you don’t have as much freedom to change the other three DSes on the fly.

NOTE: Thank Alistair if this works, and blame me if it doesn’t. I’m simply tweaking something he’s done in the past…

Thanks! I’ll see what I can do. :-)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details