Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.1

Request #18983 Enhanced link formatting with <li> tags
Submitted: 2011-11-12 02:56 UTC
From: mpgjunky Assigned: quipo
Status: Assigned Package: Pager (version 2.4.8)
PHP Version: 5.3.8 OS: Fedora 14 x64
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 16 - 7 = ?

 
 [2011-11-12 02:56 UTC] mpgjunky (Michael Mussulis)
Description: ------------ Hi, I needed to display the paging links from Structures_Datagrid, using the Smarty renderer - to be used in an un-ordered list (<ul>) tag. Therefore I needed each link wrapped inside an <li> tag, but I could not find a proper, simple method of achieving this. Perhaps I am wrong on this, and please forgive me if I am, but studying the code I noticed that the <a> tags has no pre/post options. Therefore, I propose a little change with the introduction of an option: var $_linkContainer = "li"; and used like: return sprintf('%s<a href="%s"%s%s%s%s title="%s">%s</a>%s', empty($this->_linkContainer) ? '' : '<'.$this->_linkContainer.'>', htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'), empty($this->_classString) ? '' : ' '.$this- >_classString, empty($this->_attributes) ? '' : ' '.$this- >_attributes, empty($this->_accesskey) ? '' : ' accesskey="'.$this->_linkData[$this- >_urlVar].'"', empty($onclick) ? '' : ' onclick="'.$onclick.'"', $altText, $linkText, empty($this->_linkContainer) ? '' : '</'.$this->_linkContainer.'>' ); Furthermore, I would go as far as saying that the placing the 'current page class' in a <span> tag is a little too rigid, and the code does not allow for a flexible approach like having in the <a> tag instead. The net result I was look for was something like: <ul> <li><a>1</a></li> <li><a class="current">2</a></li> </ul> Alternatively, instead of using {getPaging} to output the links, why not have a {getLinks} smarty registered function, like in Pager->getLinks()? That way one could output them as one pleases. If I am wrong in any, please ignore this feature request and accept my apologies. If there's a way of achieving the desired result that I may have missed, I would love to hear about it, and once again please accept my apologies. Thanks, Michael. Test script: --------------- {getPaging prevImg="< Prev" nextImg="Next >" separator="" altPrev="Previous" } ...in any smarty template Expected result: ---------------- <ul> <li><a>1</a></li> <li><a class="current">2</a></li> </ul> Actual result: -------------- <b>1</b> | <a href="blah">2</a> the standard pager output.

Comments

 [2011-11-12 03:03 UTC] mpgjunky (Michael Mussulis)
 [2012-02-25 19:48 UTC] daftmav (Atilla Hulsebos)
I completely agree with this request. The 'span' stuff should imo be deprecated, and an option to set your own wrapping html elements should be added. Kinda like how doctrine has it apparently, unfortunately I can't just switch to it. Would be great if Pager also got this kind of functionality, so we can wrap pagination in lists: // set page link display template $layout->setTemplate('<li><a href="{%url}">{%page}</a></li>');
 [2012-03-04 23:37 UTC] daftmav (Atilla H.)
After figuring out pear/Pager was on github, I decided to add a few options myself that would allow pagination in unordered list. I started out with the code from mpgjunky's patch, so thanks for that! The pull request can be found here: https://github.com/pear/Pager/pulls
 [2012-03-19 11:03 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Assigned -Assigned To: +Assigned To: quipo
 [2012-11-24 19:35 UTC] mpgjunky (Michael Mussulis)
Hi, Any chance of getting my patch merged to the official release? Cheers, Michael.