CPagination with Tabs

Dear all,

I have a problem with CPagination with Tabs .

I have 2 tabs call Tab1 and Tab2 , each of which has it own pagination.

Default active Tab is Tab1 .

The problem is : When user is on Tab2, and click to a “Page #5” button ( I don’t use ajax), the page is reloaded and the active Tab is Tab1 while expected active Tabs should be Tab2 .

Can anyone has an idea ?

I think ajax will be perfect solution for your problem without ajax will be hard

Currently, I have to do without ajax because we have to allow user to share the current url .

Any idea, even it is hard to implement.

I

Maybe appending the html id attribute to pagination links, like <paginationLink>#Tab2

Hey, how can we add this ?

Pls let me know, thank you

for testing purposes, to see if it works, directly on the url input of your browser

I mean in the production job.

In testing , I can anchor ( get hash) to get the page , and active the Tab. that should work.

Can you let me know how to append #sth in the Yii Pagination Link/

Thank you

You could probably extend CPagination class overriding createPageUrl method:


// protected/components/MyPagination.php

class MyPagination extends CPagination {

    public function createPageUrl($controller,$page) 

    { 

        $params=$this->params===null ? $_GET : $this->params; 

        if($page>0) // page 0 is the default 

            $params[$this->pageVar]=$page+1; 

        else 

            unset($params[$this->pageVar]); 

        // aditional anchor (hash) parameter

        $params['#'] = 'Tab2';

        return $controller->createUrl($this->route,$params); 

    }

}

hope it helps!

Thanks, let me try

[color="#008000"]NOTE_ moved to proper section (General Discussion for Yii 1.1.x instead of Tips, Snippets and Tutorials)[/color]