Req #18983 [Com]: Enhanced link formatting with <li> tags
| From: | michael@stellarent.com | Date: | Sat, 24 Nov 2012 14:35:48 +0000 |
| Subject: | Req #18983 [Com]: Enhanced link formatting with <li> tags | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-9368@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=18983&edit=1
ID: 18983
Comment by: michael@stellarent.com
Reported By: michael at stellarent dot com
Summary: Enhanced link formatting with <li> tags
Status: Assigned
Type: Feature/Change Request
Package: Pager
Operating System: Fedora 14 x64
Package Version: 2.4.8
PHP Version: 5.3.8
Assigned To: quipo
Roadmap Versions:
New Comment:
Hi,
Any chance of getting my patch merged to the official release?
Cheers,
Michael.
Previous Comments:
------------------------------------------------------------------------
[2012-03-19 07:03:52] doconnor
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: quipo
------------------------------------------------------------------------
[2012-03-04 18:37:07] daftmav
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-02-25 14:48:15] daftmav
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>');
------------------------------------------------------------------------
[2011-11-11 22:03:31] mpgjunky
Added #patch
bug:18983;patch:pager-add-link-container;revision:1321049011;.
------------------------------------------------------------------------
[2011-11-11 21:56:03] mpgjunky
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.
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=18983&edit=1