#6086: Problem with wrapping tag using PaginationHelper nav links
----------------------------------+-----------------------------------------
    Reporter:  biscazziere        |          Type:  Enhancement
      Status:  new                |      Priority:  Medium     
   Milestone:  1.2.x.x            |     Component:  Helpers    
     Version:  1.2 Final          |      Severity:  Normal     
    Keywords:  pagination helper  |   Php_version:  n/a        
Cake_version:                     |  
----------------------------------+-----------------------------------------
 I was trying to output paging numbers using PaginationHelper inside a
 view. I would like to ouput the numbers and prev/next links as a html
 unordered list (<ul><li>..).
 So i noticed that I could use the 'tag' key inside the $option array this
 way:

 {{{
 <?php echo $paginator->prev('« Precedenti ', array('tag' => 'li')) ?>
 <?php echo $paginator->numbers(array('separator' => null, 'tag' => 'li'));
 ?>
 <?php echo $paginator->next(' Successivi »', array('tag' => 'li')) ?>
 }}}

 The html output was not was I expected:

 {{{
 <ul class="pagination">
    <li class="current">1</li>
    <li><a href="/courses/index/page:2">2</a></li><li><a
 href="/courses/index/page:3">3</a></li>
 <a href="/courses/index/page:2"> Next »</a>
 </ul>
 }}}

 As you can see on the first page the "Next" link was not displayed inside
 a <li> tag, and that was causing layout mess.
 Looking at the code of function __pagingLink inside core paginator.php I
 noticed that this piece of code (about line 322) was probably the problem:

 {{{
 if ($this->{$check}($model)) {
         return $this->link($title, $url, array_merge($options,
 array('escape' => $escape)));
 } else {
         return $this->Html->tag($tag, $title, $options, $escape);
 }
 }}}

 There were case in which a simple link would be outputted, instead of a
 tag containing the link in my case. So I changed that lines with these:

 {{{
 if ($this->{$check}($model)) {
      if(!empty($tag)) {
         $link = $this->Html->link($title, $url, array(), null, false);
         return $this->Html->tag($tag, $link, $options, false);
      }else{
         return $this->link($title, $url, array_merge($options,
 array('escape' => $escape)));
     }
 } else {
         return $this->Html->tag($tag, $title, $options, $escape);
 }
 }}}

 This way, if the 'tag' option is set, it is returned the html tag wrapping
 the next or prev link, instead of a simple link.

 I hope this is helpful.

 Thanks.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/6086>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to