Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Clean Url Problem
  • Hi all, First, sorry for my english :) database:
    -id (ex: 1)
    -title (ex:About Me)
    -description (ex: Hello world)
    -pageurl (ex: about-me) Now, my urls: site.com/page/view/1 I want to: site:com/page/about-me How can do it? I tried in routes.php 'page/(:any)' => 'page/view/$1', and 'page/:pageurl' => 'page/view',
  • Routes don't magically retrieve data from the database. If you want this, add a route
    'page/:pageurl' => 'page/view';
    

    In your view() method, fetch the 'pageurl' param ( using $this->request()->param() );and do a database lookup.
  • Harro Verton wrote on Tuesday 7th of February 2012:
    Routes don't magically retrieve data from the database. If you want this, add a route
    'page/:pageurl' => 'page/view';
    

    In your view() method, fetch the 'pageurl' param ( using $this->request()->param() );and do a database lookup.
    how to make do it :/ controller/model/page.php
    public function action_view($id = null)
     {
      $data['page'] = Model_Page::find($id);
    
      $this->template->title = "Page";
      $this->template->content = View::forge('page/view', $data);
    
     }
    
  • In your view() method, fetch the 'pageurl' param ( using $this->request()->param() );and do a database lookup.
    

    I couldn't :(
  • If I add that route here, and use $this->request()->param('pageurl'), I get the parameter returned without problems.
  • Harro Verton wrote on Tuesday 7th of February 2012:
    If I add that route here, and use $this->request()->param('pageurl'), I get the parameter returned without problems.

    Thank you for your answer :) I will try again tomorrow
  • Sorry, my bad. The Controller doesn't have a request() method, it's a property. So it should be
    $param = $this->request->param('pageurl');
    

Howdy, Stranger!

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

In this Discussion