Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Kohana]Problem z paginacją
Forum PHP.pl > Forum > PHP > Frameworki
henio
Mam problem z paginacją, otóż wykorzystałem bibliotekę pagination i stworzyłem sobie proste stronicowanie. Jednakże przy przechodzeniu na poszczególne strony pojawia się błąd. Generowany jest np taki link http://localhost/heniek_cms/adm/menu_1/2

Tak też być powinno, ale kiedy wciskam pojawia się: Wywołana strona, adm/menu_1/2, nie może zostać znaleziona.

Kod configu:
  1. <?php
  2. /**
  3.  * @package  Pagination
  4.  *
  5.  * Pagination configuration is defined in groups which allows you to easily switch
  6.  * between different pagination settings for different website sections.
  7.  * Note: all groups inherit and overwrite the default group.
  8.  *
  9.  * Group Options:
  10.  *  directory      - Views folder in which your pagination style templates reside
  11.  *  style          - Pagination style template (matches view filename)
  12.  *  uri_segment    - URI segment (int or 'label') in which the current page number can be found
  13.  *  query_string   - Alternative to uri_segment: query string key that contains the page number
  14.  *  items_per_page - Number of items to display per page
  15.  *  auto_hide      - Automatically hides pagination for single pages
  16.  */
  17. $config['default'] = array
  18. (
  19.    'directory'      => 'pagination',
  20.    'style'          => 'digg',
  21.    'uri_segment'    => 3,
  22.    'query_string'   => '',
  23.    'items_per_page' => 2,
  24.    'auto_hide'      => TRUE,
  25. );
  26. ?>


Kod kontrolera:
  1. <?php
  2. public function index($pagenum=1)
  3.    {
  4.    $view = new View('layout/adm');
  5.    
  6.    $menu = new Admin_Menu_Model;
  7.    $view->menu = $menu->menu_adm();
  8.  
  9.    $shoutbox = new Admin_Shoutbox_Model;
  10.    $view->shoutbox = $shoutbox->shoutbox_adm();
  11.    
  12.    $view->content = new View('adm/menu/wybierz_1');
  13.    $view->content -> title = &#092;"Wybierz menu 1 poziomu\";
  14.    $view->username = Simple_Auth::instance()->get_user();        
  15.  
  16.    $view->content -> error = Session :: get('menu');
  17.  
  18.    $view->content -> ile = Simple_Modeler::factory('Admin_Menu_1')->count_all();
  19.  
  20.    $paging = new Pagination(
  21.                    array (
  22.                            'total_items' => $view->content -> ile,
  23.                            'uri_segment' => 'index',
  24.                            'base_url' => 'adm/menu_1/',
  25.                          ));
  26.    $view->content->pagination = $paging;
  27.    
  28.    $view->content -> edytuj = Simple_Modeler::factory('Admin_Menu_1') -> select('id','tekst') -> limit($paging->items_per_page, $paging->sql_offset) -> fetch_all('kolejnosc', 'ASC');
  29.  
  30.    $view->author = Kohana::config('settings.author');
  31.    $view->charset = Kohana::config('settings.charset');
  32.    $view->copyright = Kohana::config('settings.copyright');
  33.  
  34.    $view->library = new Heniek;
  35.  
  36.    $view->render(true);
  37.    }
  38. ?>


Częściowo ten problem rozwiązałem, gdyż już strony mi się wyświetlają poprawnie, ale link wygląda tak: adm/menu_1/index/2 a chciałbym mieć tak: adm/menu_1/2
c3zi
Również mam ten problem. Jedynym rozwiązaniem u mnie była zmiana w bibliotece Pagination. Może jednak jest jakieś inne rozwiązanie ?
bełdzio
nie wiem czy do konca rozumiem ale wywal

Cytat
'uri_segment' => 'index',


oraz

Cytat
$pagenum=1


i dodaj

Kod
public function __call( $name, $args )
{
$this -> index(  );
}


to tak na szybko
c3zi
  1. $oView->pagination = new Pagination(array(
  2. 'base_url' => url::site( 'pytanie/'.url::title( $aResult['title'] ).'-'.$aResult['id']).'/'.$sType.'/{page}',
  3. 'uri_segment' => 4,
  4. 'total_items' => $aResult['count_answers'],
  5. 'items_per_page' => 10,
  6. 'style' => 'digg',
  7. 'auto_hide' => true,
  8. ));


U mnie z taką konfiguracją musiałem grzebać w bibliotece Pagination, aby otrzymać link: http://local/pytanie/jakies-pytanie-21/najnowsze/3.

To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.