Controller?

edited July 2014 in Modules
I use the page modules to created some pages which is using some layout. So i have to pass some vars to saved page in the data base, i am thinking to use a controller page to do some database queries. However one question , currently i am setting the routing to this page like "en/home" which means it will access the page using http://localhost/cms/en/home. I suppose i need to create a en.php controller with codes such as "class En extends CI_Controller" then put home as a function. However is this correct? is it possible i create a home.php controller which is neater and yet i can still use "en/home" as the route? "en/" will always be a prefix for all pages.

Comments

  • edited 12:55AM
    You could create a Home controller and setup a route. If you don't want to use a controller, you can create a view file at views/en/home.php and that view will automatically be used with the main layout:
    http://docs.getfuelcms.com/general/pages-variables#view_file

    If you want to avoid people from accessing /home, you can setup a redirect:
    'home' => 'en/home'
    http://docs.getfuelcms.com/general/redirects
  • edited 12:55AM
    i dont get this part, i thought if i create a home.php controller with home class, then i can only access this page by http://localhost/cms/home, i cant access it using http://localhost/cms/en/home. As you said to use a route, how can i do that?
  • edited July 2014
    solved by modify config/routes.php, however, this kind of changes can only done by hard coding, is it possible i make an editable pages with only "location" as page variables. so that by changing this location param i am able to route any modified path to home.php controller? if it is possible, any hint to do it?
  • edited 12:55AM
    I'm not quite sure I follow what you are trying to do.

    Also, it looks like by the "en" that you are creating a multi-language site. FUEL has functionality built into it to help handle that including injecting the language segment (e.g. "en") into URLs automatically.
  • edited 12:55AM
    How to do that using the language segment
  • edited 12:55AM
    Sorry... thought I provided a URL. The following page provides a URL: http://docs.getfuelcms.com/general/localization
Sign In or Register to comment.