Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
pagination routes problem 1.5.1 Bug/Error
  • Hi.

    I'm having trouble routing for paging.

    public function action_yorumlarim() {
    $pagination = \Pagination::forge('pagination', array(
                        'pagination_url' => \Uri::base(false) . 'yrm/',
                        'total_items' => Model_Yrm::find()->count(),
                        'per_page' => 2,
                        'uri_segment' => 3
                       // 'num_links' => 5,
                    ));

    $data['Yrm'] = Model_Yrm::find()
                    ->where('user_id', $uye[1])
                    ->order_by('created_at', 'desc')
                    ->offset($pagination->offset)
                    ->limit($pagination->per_page)
                    ->related(array('user', 'ent'))
                    ->get();

            $data['sfl'] = $pagination->render();
            $this->template->title = "st";
            $this->template->content = View::forge('yrm/other', $data);
    }

    in routers.php codes:

    'yrm/(:num)' => 'yrm/other/$1'


    I wonder where you make mistakes. Why does the routing
  • What trouble? What doesn't work, what happens, what do you want to happen?

    First issue I see is that you render the pagination in the controller. This will produce HTML, which you have to pass to the view using set_safe(), otherwise it will be encoded and displayed as text.
  • Hello

    In this code on html pages are output. But the result is always the same if you changed that when I come routing through routes.

    When I wrote http://localhost/yrm/2 always returns the same result. But when I http://localhost/yrm/other/3 works.
  • When I am having a problem routing through routes.php. I think I'm doing it wrong orientation.
  • Your route looks fine, so I don't think that is the case. Is there another route that captures this URI first?
  • No. 

    Routes running smoothly lifted.
    Routes routing does not work when I do.
  • What does your entire routes.php look like?
  •     '_root_' => 'entryler/index', // The default route
        '_404_' => 'welcome/404', // The main 404 route

        'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
        'knl/(:any)/(:any)' => 'entrl/index/$1/$2',
        'szl/(:any)/(:any)' => 'entlr/v/$1/$2',
        'giris' => 'users/login',
        'uyeol' => 'users/register',
        'profilim' => 'users/profil',
        'sss/et/(:any)' => 'skyt/create/$1',
        'cks' => 'users/logout',
        'sfr' => 'users/sfr/',
        'ent' => 'entlr/entm/',
        'yrm/(:any)' => 'yrm/other/$1', 
        'yrm' => 'yrm/other/', // paginated index pages
        'yrm/(:any)/(:any)' => 'yrmlr/view/$1/$2',
        'yrm/(:any)' => 'yrmlr/view/$1'
  • So 'http://localhost/yrm/2' is matched by the 'yrm/(:any)' => 'yrm/other/$1', line.

    I wouldn't know why it would not route to that. You have a controller called "Controller_Yrm", and it has a method called "action_other"? It is called at all? Or do you see your 404 page?

    If
    http://localhost/yrm/other/2 works if you type it in, I wouldn't know why this route shouldn't work.
  • hello

    routes.php now erased in the definitions.

    I realized after the data has not changed at yrm/other/2. There are a total of 18 records, but 2 comes after the page is always the same records.

    Yes action_other have such a method. This is in addition to the problems with the page numbers in the following code showing the side view.

    echo Pagination::instance('pagination')->render();

    However, the http://localhost/yrm/1 url comes in the form. http://localhost/yrm/other/1 to the arrival of the original, but that does not happen.
  • Can you share a code sample application running?
  • Hello
    Now I use the version 1.5.1 release. I have a paging bug. the same procedure 1.4. When I try to release running smoothly.

    The following code 1.4. working version of the 1.5.1 version, but does not work.

    Please help.


  • <?php

    class Controller_Messages extends Controller_Template {

        public function action_index() {
            $messages = Model_Message::find('all');
            $view = View::forge('messages/index');
          

             $view->set('messages',$messages);
            $this->template->title = "Messages s";
            $this->template->content = $view;
        }
        
        public function action_yorumlarim(){
             $view = View::forge('messages/yorumlarim');
            
            $pagination = Pagination::forge('pagination', array(
                        'pagination_url' => \Uri::create('yorumlarim/sayfa'), //Uri::base(false).'yorumlarim',
                        'total_items' => Model_Message::find()->count(),
                        'per_page' => 2,
                        'uri_segment' => 3,
                        'num_links' => 5,
                    ));
            //$messages = Model_Message::find('all');
            $messages = Model_Message::find()
                    ->order_by('created_at', 'desc')
                    ->offset($pagination->offset)
                    ->limit($pagination->per_page)
                    ->get();
     
             $view->set('messages',$messages);
            $this->template->title = "Messages s";
            $this->template->content = $view;
        }

    routes.php code:

    <?php

    return array(
        '_root_' => 'messages/index', // The default route
        '_404_' => 'welcome/404', // The main 404 route

        'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
        'yorumlarim' => 'messages/yorumlarim',
        'yorumlarim/sayfa' => 'messages/yorumlarim',
        'yorumlarim/sayfa/(:any)' => 'messages/yorumlarim/$1',
    );
  • Shouldn't this

    pagination_url' => \Uri::create('yorumlarim/sayfa'), //Uri::base(false).'yorumlarim',

    be

    pagination_url' => \Uri::create('messages/yorumlarim/sayfa'), //Uri::base(false).'yorumlarim',

    since it's a method in the messages controller? Which makes the pagination uri_segment 4 instead of 3?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion