Welcome Guest, Not a member yet? Register   Sign In
Add another segment after the pagination segment
#1

[eluser]SteveBluck[/eluser]
My Controller

Code:
//Total rows shown per page
        $per_page = 10;
        //Query the database to see how many there are
        $total = $this->db->count_all('questions');
        //Display the correct rows with the pagination
        $data['questions'] = $this->theory_model->get_questions($per_page, $this->uri->segment(3));
        
        //Pagination settings
        $base_url = site_url('dashboard/theory/');
        $config['base_url'] = $base_url;
        $config['total_rows'] = $total;
        $config['per_page'] = $per_page;
        $config['uri_segment'] = '3';

        $this->pagination->initialize($config);
        
        $this->load->view('theory_view', $data);

This generates links like this /10, /20/ 30 etc which is good. However I wish /#tab2 to be added to the end of each link.

Does anyone have any solutions to this?

Thanks
#2

[eluser]SteveBluck[/eluser]
Any help would be greatly appreciated.

Thank you.
#3

[eluser]slowgary[/eluser]
I don't see a way in the pagination class to do that. I added a few parameters before the pagination uri_segment, but not after. Is it actually an anchor within the page, as specified by the pound sign (#)?

The only way I can think of without creating your own pagination or extending the pagination class is by using JavaScript. You could cycle through each link and add the anchor to each element's href attribute. This wouldn't really be the best solution, and unless it's for a corporate network where you can guarantee a certain environment, I wouldn't use it.
#4

[eluser]SteveBluck[/eluser]
Hmm, I'm not sure how to do that. But yeah I have tabs on the webpage, and after you click a pagination link the second tab needs to be the first active, and to do this I need to add /#tab2 at the end of the url.
#5

[eluser]slowgary[/eluser]
It's hard for me to imagine your scenario. You have pagination links, whereupon clicking one the user should be taken to that given page, but any given page will ALWAYS have a set of JavaScripted tabs where the second tab needs to be active?

Maybe there's a better way, but I'll wait to see if you can clarify my above mentioned confusion before I spend any brain cycles on something.

I'm sure you could just store the markup returned by the call to $this->pagination->create_links(), then traverse it and add your #anchor using a str_replace or regex or something, but it seems like a bad solution.




Theme © iAndrew 2016 - Forum software by © MyBB