-
☆ A M B ☆
- 1,231 Posts
Ok I’m still a PHP noob...
Basically I have been working with a pagination script which I have working quite well but I want to add some counting features as well. I want to count the results depending on the page that is selected by the user, again I have this working but I would like my count at the top of my page rather than the bottom. Simple as it sounds, I can’t figure out how to return a value to the start of my script after counting through the while loop. Do I have to create another while loop at the start of my script? I doubt I do as it’s double handling but my knowledge is limited.
Thanks.
-
☆ A M B ☆
- 24,524 Posts
Since you are interested in the placement of the output, and this is MODx, you might be interested in the concept of placeholders.
$modx->setPlaceholder('Name', $value);
The value is now stored in the $modx->placeholders array.
http://wiki.modxcms.com/index.php/API:setPlaceholder
Then in your HTML, you can use [+Name+] wherever you want $value displayed.
-
☆ A M B ☆
- 1,231 Posts
Thank you Susan.
I have my snippet dealing with the while loop and the foreach... outputting the results as a list and at the end of the script the placeholder result. IN the actual document I have put the placeholder above the snippet call and looks exactly how I wanted it. Seems to be the best way for my needs.