0

I'm working on a quick plugin to output where you are in a paginated list of entries but am having problems doing mathematical calculations on plugin parameters when one of them is using {super_search_total_results}.

This is what I have so far:

$output        = '';
$per_page      = ee()->TMPL->fetch_param('page_num'); // e.g. 9
$total_entries = ee()->TMPL->fetch_param('total_results'); // e.g. 50
$output        = $per_page + $total_entries;

return $this->return_data = $output;

And in the template I have:

{exp:td_tours_advanced_count
    page_num='6'
    url_segment="{last_segment}"
    total_results='{super_search_total_results}'
}

So with the above, if my total results are 14 then the expected result of $output should be 20 but instead I get 6. If I set $output to just equal $total_entries then the result is 14.

It's only when I try to use $total_entries in a mathematical operation that it always seems to evaluate to 0, i.e. if I do * or / I get 0.

But if I change the plugin parameter in the template to

{exp:td_tours_advanced_count
    page_num='6'
    url_segment="{last_segment}"
    total_results='14'
}

then the $output is as expected and all other mathematical operations work correctly. I've tried adding parse='inward' to the plugin but to no avail.

So why is that {super_search_total_results} parses OK as a string but when trying to use it as an integer, it always returns 0 (I've tried converting it to an integer/float but the output is still 0).

0

As soon as I update the question I find the answer. For some reason {super_search_total_results} as the plugin parameter doesn't work but {exp:super_search:results limit="1"}{super_search_total_results}{/exp:super_search:results} does.

It would still be interesting to know why the first only works when trying to output the string directly and not when using it in mathematical operations, but the latter does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.