alan Posted March 17, 2014 Posted March 17, 2014 Sorry this is likely such a simple question, but if I've got some happy pagination code like this: $out .= "<div id='galleryPageN'>" . $a->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Previous", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>" )) . "</div>"; that is working AOK. But I want to detect when the pagination will or will not be present in order to render or not render the holding DIV (I want to avoid an empty DIV). I am sure it's got to be a simple piece of PW+PHP testing $a to work this out but I've been tripping over trying to work it out. Thanks if you've time to ping me a comment back on this, cheers, -Alan
Joss Posted March 17, 2014 Posted March 17, 2014 Cant quite think how to do this, but since this is based on a count, if you check to see whether your count is above or equal to the value when pagination kicks in, then if it is, display the pagination. What I am not sure about is what happens on page two.... 1
alan Posted March 17, 2014 Author Posted March 17, 2014 Thanks Joss, there is a loop further up I'd ignored since the comment that it came with made me not think it would be testable for this (in fact I had not yet worked out what it did exactly!). I have used the code from everfreecreative's great post as a starting point in the making of this hence. It's been excellent I'll go back and look at that for loop and see it it's as simple as that and either way, thanks for the suggestion!
Soma Posted March 17, 2014 Posted March 17, 2014 Just set to a variable and test if it got any markup... $pager = $a->renderPager(...); if($pager) $out .= "..."; 1
alan Posted March 17, 2014 Author Posted March 17, 2014 Thanks again for the simple PHP 101 Soma! Perfect! PS: I had been print_r'ing and seeing the content of the array in both conditions (with and without pagination) and not realised that although both were arrays with data only one would **return** something and that therefore I could do a simple test! I've learnt more than I expected, thanks again and glad I asked
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now