bcit-ci / CodeIgniter

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
18.27k stars 7.61k forks source link

Pagination Link. It´s not a really issue, but it drives me mad. #5623

Closed letsmg closed 5 years ago

letsmg commented 5 years ago

Hey guys, at first, congratulations for so much working in CI.

My request it´s just a little improvement, if possible.

When using the paging class with bootstrap classes 4 for example, it works, but the "a tag" formed by the IC does not cover the entire link tag, thus requiring the user to click exactly on the page number.

This disrupts UX a lot because the bootstrap class causes the cursor to become the link cursor (the hand clicking), even though it is outside the scope of "tag a".

This gives the impression to the end user that the link is broken.

I hope you understand what I mean, my english isn't so good. Thank you guys very much.

narfbg commented 5 years ago

Sorry, but I'm not a front-end developer and I couldn't care less about Bootstrap, so ... I don't mind having this work the way you want it, but you'll have to suggest a patch for it yourself.

aanbar commented 5 years ago

This is fully configurable through a config file, You may add whatever classes & opening/closing tags you want, If you are using the latest version of CI then everything should be OK.

I am thinking of creating a default config file for pagination that utilize bootstrap 4 style & add it to the application folder. but I don't know if that would be OK @narfbg ? I think most people now either use material design or bootstrap for their work.

letsmg commented 5 years ago

Thank you for be kind in your response Aanbar. I´ve already receveid another response really unpleased. Well, i really wasn´t capable of fix it with the "config" options. I you want, can give a look at my code below, but i fixed it by myself with JQuery. $this->load->library('pagination'); $config['base_url'] = base_url('posts'); $config['total_rows'] = $dados['conta_posts_ativos']; $config['per_page'] = $por_pagina; $config['use_page_numbers'] = TRUE;

$config['full_tag_open'] = '

'; $config['num_tag_open'] = '
  • <span class="page-link">'; $config['num_tag_close'] = '
  • '; $config['cur_tag_open'] = '
  • <span class="page-link">'; $config['cur_tag_close'] = '<span class="sr-only">(current)
  • '; $config['next_tag_open'] = '
  • <span class="page-link">'; $config['next_tagl_close'] = '<span aria-hidden="true">»
  • '; $config['prev_tag_open'] = '
  • <span class="page-link">'; $config['prev_tagl_close'] = '
  • '; $config['first_tag_open'] = '
  • <span class="page-link">'; $config['first_tagl_close'] = '
  • '; $config['last_tag_open'] = '
  • <span class="page-link">'; $config['last_tagl_close'] = '
  • '; $config['first_link'] = 'Primeira'; $config['last_link'] = 'Última';

    $this->pagination->initialize($config);

    If i´m not missunderstanding it, the "a tag" is always placed inside the "li tags". So i thought, that it would be needed just place "li tags" outside "a tag".

    That is the result by the way: <a href="http://localhost/cognitiva_concursos/posts/2" data-ci-pagination-page="2">2

    And that is how it should work, "i guess" <a href="http://localhost/cognitiva_concursos/posts/2" data-ci-pagination-page="2"> 2

    Anyway, thanks for your time, forgive my bad english, or if i´m mistaken at all. I informed this issue, because i thought if i´m right, that´s should be easy to fix.

    Best regards Luiz.

    Em qui, 1 de nov de 2018 às 14:53, aanbar notifications@github.com escreveu:

    This is fully configurable through a config file, You may add whatever classes & opening/closing tags you want, If you are using the latest version of CI then everything should be OK.

    I am thinking of creating a default config file for pagination that utilize bootstrap 4 style & add it to the application folder. but I don't know if that would be OK @narfbg https://github.com/narfbg ? I think most people now either use material design or bootstrap for their work.

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bcit-ci/CodeIgniter/issues/5623#issuecomment-435123411, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjmmPEBh1H_rCm0MJ6R17UoKktqaeayks5uqzUAgaJpZM4Xt7iA .

    --


    Att. Luiz Eduardo Técnico em Informática / Desenvolvedor Web PHP / Aux. Administrativo Fone/Whatsapp (35)9.9163-0427 Recado Juliana (35)9.9148-2449

    aanbar commented 5 years ago

    No problem.

    Your a tag doesn't have to be outside the li tag, You're just missing $config['attributes'] = ['class' => 'page-link'];

    which adds a class 'pagin-link' to a attribute

    And you don't have to define your config each time you create a pagination, you can use config file instead in application/config/pagination.php

    letsmg commented 5 years ago

    Thank you very much Mr. Aanbar, i really didn´t see that option.

    About the config file i didn´t know as well cause that file isn´t present on a fresh instalation of CI, just like the migration file, that i came to know about few days ago.

    Anyway, could you give me just one little more information? I have searched on stackoverflow, but with no success. And the CI docs doesn´t give more information.

    In this pagination file, how can i implement more than one configuration, is it possible?

    Thanks again.

    Em sáb, 3 de nov de 2018 às 13:03, aanbar notifications@github.com escreveu:

    No problem.

    Your a tag doesn't have to be outside the li tag, You're just missing $config['attributes'] = ['class' => 'page-link'];

    which adds a class 'pagin-link' to a attribute

    And you don't have to define your config each time you create a pagination, you can use config file instead in application/config/pagination.php

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bcit-ci/CodeIgniter/issues/5623#issuecomment-435598918, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjmmJpiG1d4_88rQIh6-xG-_k0xMTAvks5urb40gaJpZM4Xt7iA .

    --


    Att. Luiz Eduardo Técnico em Informática / Desenvolvedor Web PHP / Aux. Administrativo Fone/Whatsapp (35)9.9163-0427 Recado Juliana (35)9.9148-2449

    aanbar commented 5 years ago

    Create a file in application/config/pagination.php

    Add the following for Bootstrap 4:

    <?php
    $config = array(
        'full_tag_open'     => '<nav aria-label="Page navigation"><ul class="pagination justify-content-center">',
        'full_tag_close'    => '</ul></nav>',
        'first_tag_open'    => '<li class="page-item">',
        'first_tag_close'   => '</li>',
        'last_tag_open'     => '<li class="page-item">',
        'last_tag_close'    => '</li>',
        'prev_tag_open'     => '<li class="page-item">',
        'prev_tag_close'    => '</li>',
        'prev_link'         => '&laquo;',
        'next_tag_open'     => '<li class="page-item">',
        'next_tag_close'    => '</li>',
        'next_link'         => '&raquo;',
        'num_tag_open'      => '<li class="page-item">',
        'num_tag_close'     => '</li>',
        'cur_tag_open'      => '<li class="page-item active"><span class="page-link">',
        'cur_tag_close'     => '<span class="sr-only">(current)</span></span></li>',
        'attributes'        => ['class' => 'page-link']
    );
    

    When you want to use pagination, You just pass (base_url, total_rows, per_page) to your pagination->initialize method without having to give it the styles every time

    letsmg commented 5 years ago

    That i got it, but what i would like to know is if it´s possible use more than one "config" in this file.. example:

    pagination.php:

    $config1 = array( $config['base_url'] = base_url('posts'); 'full_tag_close' => etc... ), $config2 = array( $config['base_url'] = base_url('topics'); //different sql select 'full_tag_close' => etc... ) and so in controller use:

    $this->pagination->initialize($config2); //or something else

    because i use two different pagination url´s

    Em dom, 4 de nov de 2018 às 12:41, aanbar notifications@github.com escreveu:

    Create a file in application/config/pagination.php

    Add the following for Bootstrap 4:

    <?php $config = array( 'full_tag_open' => '

    ', 'first_tag_open' => '
  • ', 'first_tag_close' => '
  • ', 'last_tag_open' => '
  • ', 'last_tag_close' => '
  • ', 'prev_tag_open' => '
  • ', 'prev_tag_close' => '
  • ', 'prev_link' => '«', 'next_tag_open' => '
  • ', 'next_tag_close' => '
  • ', 'next_link' => '»', 'num_tag_open' => '
  • ', 'num_tag_close' => '
  • ', 'cur_tag_open' => '
  • ', 'cur_tag_close' => '(current)
  • ', 'attributes' => ['class' => 'page-link'] );

    When you want to use pagination, You just pass (base_url, total_rows, per_page) to your pagination->initialize method without having to give it the styles every time

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bcit-ci/CodeIgniter/issues/5623#issuecomment-435675166, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjmmBGTDzja8w-leOvp55ordA-1DaXFks5urvyAgaJpZM4Xt7iA .

    --


    Att. Luiz Eduardo Técnico em Informática / Desenvolvedor Web PHP / Aux. Administrativo Fone/Whatsapp (35)9.9163-0427 Recado Juliana (35)9.9148-2449

    aanbar commented 5 years ago

    You can pass your extra config in controller using the initialize method for pagination library, it will still automatically load the styling from the pagination config file, so you just need to add the missing config like the base_url ...etc

    static configs goes in config file, variable config goes in controller ... initialize method will merge both giving the priority to things you pass to initialize method so you can override configs when you want

    letsmg commented 5 years ago

    Thank you very very much Aanbar,

    you really helped me a lot.

    Congrats for your work, you guys are awesome!

    See ya!

    Em seg, 5 de nov de 2018 às 16:03, aanbar notifications@github.com escreveu:

    You can pass your extra config in controller using the initialize method for pagination library, it will still automatically load the styling from the pagination config file, so you just need to add the missing config like the base_url ...etc

    static configs goes in config file, variable config goes in controller ... initialize method will merge both giving the priority to things you pass to initialize method so you can override configs when you want

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bcit-ci/CodeIgniter/issues/5623#issuecomment-435973314, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjmmPuvhRULkvpd4TvjTz8E6MF1RDN-ks5usH2KgaJpZM4Xt7iA .

    --


    Att. Luiz Eduardo Técnico em Informática / Desenvolvedor Web PHP / Aux. Administrativo Fone/Whatsapp (35)9.9163-0427 Recado Juliana (35)9.9148-2449

    narfbg commented 5 years ago

    I am thinking of creating a default config file for pagination that utilize bootstrap 4 style & add it to the application folder. but I don't know if that would be OK @narfbg ? I think most people now either use material design or bootstrap for their work.

    @aanbar No.

    I´ve already receveid another response really unpleased.

    @letsmg This is a bug tracker, attached to a code repository. It's not a support ticket system.

    When you come here, it should be to participate in CI's development; not for someone else to work for you. We have a forum board where you can seek help if you need it.