Search

Probably a question for @brendo?

Is there a way to use math together with the output of a {$param} in the datasource pagination field »Page Number«? Essentially I would want to do something like:

{$param + 1}

and of course

{$param - 1}

But apparently the param is evaluated in a different way. I tried {$param} -1 and some other possibilities too. Is there a way to do this?

Unfortunately, there is currently no way to evaluate expressions as parameters in the core.

What are you trying to accomplish? Maybe there's another way?

Thanks Brendo,

I simply need the numbers above and below a numerical value that is passed via an url-parameter. I guess a custom ds should be able to do that. But thats not quite what I am best in …

Is making a new parameter or variable with the existing parameter in your template not an option?

@plenaforma unfortunately not, since I need the modified params for datasource chaining. Thus I cannot process it in the template.

I’m trying to build a custom DS for this. The only thing I haven’t managed to achieve is to import a page-param from the param-pool into the DS. Any hints?

Got it! I made this Custom DS:

<?php

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

class datasourcenextprev extends SectionDatasource
{
    public $dsParamROOTELEMENT = 'nextprev';

    public function __construct($env = null, $process_params = true)
    {
        parent::__construct($env, $process_params);
        $this->_dependencies = array('$foto-id');
    }

    public function about()
    {
        return array(
            'name' => 'Nextprev',
            'author' => array(
                'name' => 'Alexander Rutz',
                'website' => 'http://62.154.206.77',
                'email' => 'alex@animaux.de'),
            'version' => 'Symphony 2.5.2',
            'release-date' => '2014-12-23T10:05:50+00:00'
        );
    }

    public function getSource() { return false; }
    public function allowEditorToParse() { return false; }

    public function execute(array &$param_pool)
    {
        $position = Frontend::instance()->Page()->_param['position'];
        $param_pool['ds-prev'] = $position - 1;
        $param_pool['ds-next'] = $position + 1;
    }
}

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