Search

I have a datasource called job-table with the following code and filters in the php file attached to it:

 Class datasourcejob_table extends Datasource{

    public $dsParamROOTELEMENT = 'job-table';
    public $dsParamORDER = 'desc';
    public $dsParamLIMIT = '6';
    public $dsParamREDIRECTONEMPTY = 'no';
    public $dsParamPARAMOUTPUT = 'company-logo';
    public $dsParamSORT = 'system:id';
    public $dsParamSTARTPAGE = '{$url-p:1}';
    public $dsParamHTMLENCODE = 'yes';

    public $dsParamFILTERS = array(
        'id' => '{$id}',
        '149' => 'yes',
        '84' => 'equal to or earlier than {$today}',
        '85' => 'equal to or later than {$today}',
        '141' => '{$hours}',
    );

If I change the ParamSORT to anything other than system:id - anything contained or filtered by hours does no appear..

So the url jobs/full-time/ displays no entries as for jobs/part-time/ displays nothing… but /jobs/ displays correclty

Any takers as to where to start here?

Also can dsparamSORT have more than one listed by delimited commas?

Also can dsparamSORT have more than one listed by delimited commas?

Nope.

So the url jobs/full-time/ displays no entries as for jobs/part-time/ displays nothing… but /jobs/ displays correclty

Are all of these pages using the same Data Source? The difference of page doesn’t make sense to me.

What values have you tried in $dsParamSORT? Are you editing this file directly, or saving through the Data Source editor?

HAve edited directly the data source so that dsparamSORT = {$url-s:salary-from}

and dsparamORDER = {$url-o:desc}

The is not a real url as such.. it’s the same page as jobs/ just with a a url parameter passed to the session monster.. it’s also nice to visually have a url to go to if your’e looking for fulltime or part time jobs.

Different data sources would be a nightmare me thinks.. but if it’s the only solution please tell me so!

If I try anything other than System:id the the DS Editor I get no results on the full-time and part-time pages either. jobs/ is displaying as usual though, whichever way I do it!

dsparamSORT = {$url-s:salary-from}

That’s your problem. Since the Data Source editor doesn’t provide a free-text input, the Data Source code will not evaluate environment parameters like this. When the DS executes it will take that value literally, rather than evaluating its value.

Try:

$dsParamSORT = (isset($_GET['s'])) ? $_GET['s'] : 'salary-from';

This is PHP, using the ternary operator. If the s variable is set in the querystring it will be used, otherwise it will fall back to salary-from. When customising a DS or Event be sure to set the allowEditorToParse function to return false to prevent yourself re-saving the file in the backend editor and losing your changes!

Would that be the same for the {$url-o:order} ? or is that ok as it is?

Tried your above solution and I get a http 500 error what does that mean?

I get a http 500 error what does that mean?

Means the code is bad ;-) Try this:

public $dsParamSORT = (isset($_GET['s']) ? $_GET['s'] : 'salary-from');

And yes, you’ll probably need to do the same for the ORDER member too.

Tried that.. adding public before the line of previous code.. is that the only change?

Nope.. no luck there. just get blank page completely! no error, just blank page. weird.

Why does it work with system:id but nothing else?

Nope.. no luck there. just get blank page completely! no error, just blank page. weird.

I dont think you can put conditional statements like that in a class variable declaration. Instead, set it to NULL and declare it in the constructor/grab function. E.G.

public $dsParamSORT = NULL;
...
public function grab(&$param_pool){
    $this->dsParamSORT = (isset($_GET['s']) ? $_GET['s'] : 'salary-from');
    ...

Why does it work with system:id but nothing else?

Just to clarify, the SORT value needs to be the element name of a field in your section. system:id is a special field name that triggers Symphony to use the entry ID value for sorting. We name-spaced it with system: so it would never clash with fields you create in your sections.

You should be able to use the curly brace syntax for SORT and ORDER values. So, {$url-s:salary-from} should work.

Make sure that s is a valid field element name and o is either desc, asc or random.

One thing to try is put the following code at the top of your grab() function:

print 'order: "' . $this->dsParamORDER . "'" . General::CRLF
. 'limit :"' . $this->dsParamLIMIT . "'" . General::CRLF
. 'sort :"' . $this->dsParamSORT . "'" . General::CRLF
. 'start page :"' . $this->dsParamSTARTPAGE . "'" . General::CRLF;

print_r($this->dsParamFILTERS);
exit();

That should give you some idea what’s going on.

The weird thing with this is that I have a page setup with a datasource called job-table

Here are the filters on the datasource:

  • System ID: {$id} Hours: {$hours} Approved: Yes From Date:equal to or earlier than {$today} To Date:equal to or later than {$today}

When I configure the SORT and ORDER as follows dsParamSORT = {$url-s:salary-from} and dsParamORDER = {$url-o:desc}

My page www.domain.com/jobs/ works great.. and I can sort by many categories based on changing the s parameter on the page using session monster to another field in my datasource called “jobs” it’s only when I filter by hours to a new parameter adding www.domain.com/jobs/full-time/ or www.domain.com/jobs/part-time/ do I see no results.

The part time and full time urls are not new pages just filtering parameters.

Below is my data-source file for job-table

Tried the paramPool suggestion, still get blank entries..

When I debug the page www.domain.com/jobs/full-time/ I see no entries listed inside job-table bar the job table container and the pagination results.. counting the entries somehow but not pulling/ displaying them behind the jobs/full-time/ and /jobs/part-time/ parameters.. /jobs/ displays correcly though.. any ideas if there’s anything amis in the data-source php below?

  require_once(TOOLKIT . '/class.datasource.php');

  Class datasourcejob_table extends Datasource{

    public $dsParamROOTELEMENT = 'job-table';
    public $dsParamORDER = '{$url-o:desc}';
    public $dsParamLIMIT = '6';
    public $dsParamREDIRECTONEMPTY = 'no';
    public $dsParamPARAMOUTPUT = 'company-logo';
    public $dsParamSORT = 'system:id';
    public $dsParamSTARTPAGE = '{$url-p:1}';

    public $dsParamFILTERS = array(
        'id' => '{$id}',
        '149' => 'yes',
        '84' => 'equal to or earlier than {$today}',
        '85' => 'equal to or later than {$today}',
        '141' => '{$hours}',
    );

    public $dsParamINCLUDEDELEMENTS = array(
        'system:pagination',
        'job-id',
        'cymraeg-job-title',
        'english-job-title',
        'approved',
        'cymraeg-location',
        'english-location',
        'from-date',
        'to-date',
        'asap',
        'salary-from',
        'salary-to',
        'negotiable',
        'term',
        'hours',
        'cymraeg-normal-hours-per-week',
        'english-normal-hours-per-week',
        'cymraeg-duration-dates-for-temporary-fixed-term-jo',
        'english-duration-dates-for-temporary-fixed-term-jo',
        'cymraeg-reference',
        'english-reference',
        'cymraeg-description',
        'english-description',
        'additional-instructions-from-the-advertiser',
        'cymraeg-how-to-apply',
        'english-how-to-apply',
        'contact-name',
        'telephone',
        'email',
        'cymraeg-company-name',
        'english-company-name',
        'company-logo',
        'welsh-website-url',
        'english-website-url',
        'cymraeg-address',
        'english-address'
    );

    public function __construct(&$parent, $env=NULL, $process_params=true){
      parent::__construct($parent, $env, $process_params);
      $this->_dependencies = array();
    }

    public function about(){
      return array(
           'name' => 'Job Table',
           'author' => array(
              'name' => 'moono2',
              'website' => 'http://www.mydomain.co.uk',
              'email' => 'blanked out for security'),
           'version' => '1.0',
           'release-date' => '2009-11-16T17:53:37+00:00');  
    }

    public function getSource(){
      return '12';
    }

    public function allowEditorToParse(){
      return true;
    }

    public function grab(&$param_pool){
      $result = new XMLElement($this->dsParamROOTELEMENT);

      try{
        include(TOOLKIT . '/data-sources/datasource.section.php');
      }
      catch(Exception $e){
        $result->appendChild(new XMLElement('error', $e->getMessage()));
        return $result;
      }  

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

Uh code not showing?

Fixed the code rendering.

Ta, really baffled here.. cos it works when I set the {$url-s:salary-from} in the dsParamSORT on the www.domain.co.uk/jobs/ page,

but domain.co.uk/jobs/full-time or part-time shows nothing … but the pagination knows how many entries are there cos I see the amount of pages are the same when using system:id or $url-s:salary-from but yet there are no entries for jobs in the source when I check under ?debug but there are under the www.domain.co.uk/jobs/ url … I’m lost as to why this one line is causing me jip.

system:date seems to work but it’s not what I want.. as in system:id and system:date both display entries under domain.co.uk/jobs/full-time and part-time but anything else like {$url-s:salary-from} throws a wobbly.

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