Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
lots of url in one module
  • i have one module and would like to make or display 10 pages with url http://pit.localhost/t_history/1 and http://pit.localhost/t_history/2 and up to 10, but i kinda confuse if how am i gonna suppose to do it...do i have to make a lot of controllers? or does anyone does have a efficient way of doing it.
  • and follow up question, is my understanding correct that if the link is t_history/search/index does it mean that it redirects to a module name t_history and a .php file named search and a function name action_index like the same as t_affair/edit/edit leads to a action_edit function inside edit.php?
  • HarroHarro
    Accepted Answer
    t_history/search/index:
    - could be: module t_history, controller Controller_Search, action_index
    - or: controller Controller_T_History, action_search, parameter 'index'
    - else a 404 (unless you have a route capturing this URL)

    As to your first question, if you don't want the controller name and/or the action name in the URL, you need to define a route for it (in this case in your t_history module config/routes.php):

    't_history/(:num)' => 't_history/pages/show/$1',

    which would redirect the request to the controller Controller_Pages, action_show and will pass the number as an argument to the action.
  • thank you so much sir :)
  • how to pass a number sir with t_history/(:num)? is it history_forward( t_history/1) or am i wrng....

    and another one, i added 't_history/1'='t_history/tenant/index' then it work...but the problem of that page is i cannot show the next links of my pagination cause i used tenant in the set function in pagination because if i use t_history/1 there i a smarty error
  • and the url of the 10 pages should be t_history/1 to t_history/10 and i made a  't_history/1/(:num)'='t_history/tenant/index/$1' is this ok?
  • it works well now....but my problem now is when i click next link or other links it goes back to page number 1.....
  • here is the real situation...i defined routes 't_history/1' => 't_history/search/tenants',
        't_history/1/(:num)' => 't_history/search/tenants/$1',
        't_history/2' => 't_history/search/affairs',
        't_history/2/(:num)' => 't_history/search/affairs/$1', then the problem is when i go to t_history/1 the page goes to page 1 but in t_history/2 goes to page 2 of pagination even if the url is change into t_history/2/1 it wont go back to page 1? do you know how could this be fixed?
  • well i changed the links into this 't_history/1' => 't_history/search/tenants',
        't_history/1/(:num)' => 't_history/search/tenants/$1',
        't_history/2' => 't_history/search/affairs',
        't_history/2/(:num)' => 't_history/search/affairs/$1', but still get the same result still still stuck in page in 1 in both pages though can't go to other links
  • correction it is change to this 't_history/tenants' => 't_history/search/tenants',
        't_history/tenants/(:num)' => 't_history/search/tenants/$1',
        't_history/affairs' => 't_history/search/affairs',
  • You need to get the page number in your controller, and use that to run the correct query.

    Any additional URI segments are passed to the controller action as parameters:

    namespace T_History;

    class Controller_Search extends \Controller
    {
        public function action_tenants($page = null)
        {
            // make sure page contains something useful
            is_null($page) and $page = 1;

            // the rest of your code using $page...
        }
    }
  • i change the value of segment from 2 to 3....can i ask what it really does? i really don't get it quite while reading the description of it the docs thanks
  • it works by the way when i change the segment...im still gonna test it with the other pages

Howdy, Stranger!

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

In this Discussion