Use math + {$param} in Data Source Pagination Field »Page Number«
This is an open discussion with 5 replies, filed under General.
Search
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.
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:and of course
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?