• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pagination not reading config file

#11
[eluser]boony[/eluser]
[quote author="InsiteFX" date="1304680140"]For the anchor_class you need to assign it a css class form your css file!
Code:
// css file.
.pager {
    background-color: #c0c0c0;
}

// anchor_class
$config['anchor_class'] = 'pager';

Not sure if your doing that, but that is how it is done.

InsiteFX[/quote]
er yup...doing that. I can style the links directly in the view, but when I assign the class directly to the anchor_class the pagination just stops working >:-(
very strange behaviour but I'm sure it is something simple (me more than likely :red: ) but I'm like a dog with a bone and will solve this

woof woof

#12
[eluser]Gyzm[/eluser]
I hate to be that guy but it's working fine for me. Only thing I can recommend is to go to bitbucket
https://bitbucket.org/ellislab/codeignit...nation.php
copy the code from there, navigate to your installation of CI system/libraries/Pagination.php and paste in the code you copied from bitbucket.

If that doesn't work it's definitely something that you're doing.

Cheers

#13
[eluser]Gyzm[/eluser]
Hey folks,

I've figured this one out.

The reason why it worked for me the first time was because I was putting my configs into their own config file within the application/config folder. When you do this the parameters are initialized via the constructor. If you open your system/libraries/Pagination.php file you'll notice that the constructor has this control structure:

Code:
if ($this->anchor_class != '')
{
    $this->anchor_class = 'class="'.$this->anchor_class.'" ';
}

This control is in the wrong spot. It needs to be moved down into the initialize() function after all of your parameters have been set. So:

Code:
function initialize($params = array())
    {
        if (count($params) > 0)
        {
            foreach ($params as $key => $val)
            {
                if (isset($this->$key))
                {
                    $this->$key = $val;
                }
            }
        }
        
        if ($this->anchor_class != '')
        {
            $this->anchor_class = 'class="'.$this->anchor_class.'" ';
        }
    }

That should get'er workin' fer ya.

#14
[eluser]bigmike7801[/eluser]
I tried your suggestion Gyzm and it still isn't working for me.

#15
[eluser]Gyzm[/eluser]
Hi bigmike,

Can I see your code? Post up your Pagination.php class as it is now plus how you're initializing it in your controller.

#16
[eluser]InsiteFX[/eluser]
Did you load the css file? You could also use style tags in your head section to see if it works! Example welcome_message view file.

InsiteFX

#17
[eluser]bigmike7801[/eluser]
[quote author="Gyzm" date="1309513277"]Hi bigmike,

Can I see your code? Post up your Pagination.php class as it is now plus how you're initializing it in your controller.[/quote]

I was unable to post the whole Pagination class due to size restrictions, so I posted what I believe was the relevant code.

Code:
/**
     * Constructor
     *
     * @access    public
     * @param    array    initialization parameters
     */
    public function __construct($params = array())
    {
        if (count($params) > 0)
        {
            $this->initialize($params);
        }


        log_message('debug', "Pagination Class Initialized");
    }

    // --------------------------------------------------------------------

    /**
     * Initialize Preferences
     *
     * @access    public
     * @param    array    initialization parameters
     * @return    void
     */
    function initialize($params = array())
    {
        if (count($params) > 0)
        {
            foreach ($params as $key => $val)
            {
                if (isset($this->$key))
                {
                    $this->$key = $val;
                }
            }
        }
        if ($this->anchor_class != '')
        {
            $this->anchor_class = 'class="'.$this->anchor_class.'" ';
        }
    }

    // --------------------------------------------------------------------

Controller

Code:
function results(){
        $this->load->library('pagination');

        $search_fields = array();

        $config['base_url'] = site_url($this->uri->uri_string());
        $config['total_rows'] = $this->jobs_m->paginate_jobs($category, $sub_category, $search_fields);
        $config['per_page'] = '3';
        $config['anchor_class'] = 'clear';
        
        $data['listings'] = $this->jobs_m->get_jobs($category, $sub_category, $search_fields, $config['per_page'], $this->uri->segment(3));
        
        $this->pagination->initialize($config);

        $this->load->view('results', $data);
    }

I'm not sure if this matters at all, but I'm using Pyrocms as well.

Thank you for your help.

#18
[eluser]bigmike7801[/eluser]
[quote author="InsiteFX" date="1309513856"]Did you load the css file? You could also use style tags in your head section to see if it works! Example welcome_message view file.

InsiteFX[/quote]

Yes the css file is loaded.

I'm also unable to get $config['first_tag_open'] or $config['$first_tag_close'] to work either.

#19
[eluser]Gyzm[/eluser]
Is this local or live? Wondering if I can view the output.

It should be noted that there are two different issues within this thread.

1 - Boony wants the "First" and "Last" links to appear. Boony, the first and last links will appear on their own when the page result range is beyond 2 pages from the currently viewed page. If you want them to appear sooner you can change it to 1. If you set to 0 you'll get the error "Your number of links must be set to a positive number". Not much you can do about that other than modify Pagination.php to work the way you want it. That being said, if you think about it, there is really no need to have first and last appear unless they are beyond a reasonable range.

2 - The anchor class issue: During my testing I discovered that if you loaded the configs through their own config file ("./application/config/pagination.php") then the anchor class would be set properly. If you take this route the configs are passed through the Pagination class' constructor. With CI 2.0.2's current Pagination class commit the anchor class check is located within the constructor so this is all well and good but if you are to pass the configs via $this->pagination->initialize($config) then the anchor class doesn't get set because the check/set control structure is in the constructor. Using $this->pagination->initialize() happens after the constructor as been called. That's why I suggested moving the anchor class check/set to the initialize method, which makes sense anyway because it's a variable that needs to be initialized. The constructor calls the initialize method so, whether you use a pagination.php config file or $this->pagination->initialize() the anchor_class check/set will always occur.

Bigmike, at this point I can only assume that $config['first_tag_open'] and $config['first_tag_close'] are working for you. The reason why you're not seeing them is the same reason Boony isn't: your results haven't gone beyond the num_links range. Default is 2 +1. It's line 197 in Pagination.php:

// Render the "First" link
Code:
if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))

I have made a pull request to commit this change but nothing has happened yet. This bug still exists.

Does this help?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.