Using URI

edited May 2012 in Modules
I have a number of links which has an ID dynamically appended to the href from the database i.e

index.php/product/{id} - the browser see's index.php/product/3 for instance.

OK I have a views file that needs to grab the ID from the URI in order to make a query relevant to the ID. Every time I visit index.php/product/3<-------a number(id)
I get a 404. How can I stop this

Thanks

Comments

  • edited May 2012
    To fix this, create a "product.php" variables file and place it at fuel/application/views/_variables/.

    Then add the following to it:
    $pages['product|product/:any'] = array('view' => 'product');
    This tells FUEL to map requests from anything at "product" to the fuel/application/views/product.php view file.
  • edited 6:51AM
    Thanks for the quick reply. I have done exactly this and visiting anything product/* still gives me a 404 error. Could it be anything else in the configs?
  • edited 6:51AM
    I have also tried this through the actual global.php and its still giving me a 404.
  • edited 6:51AM
    Is the 404 being generated by the page or is it before it even gets to the page? For example, I will often include logic in the page that if the query does not return a valid record it returns a 404 error message.

    Also, this page isn't being served up by a controller and there are no routes in place that may be causing an issue right?
  • edited May 2012
    No the page isnt connected to any controller its going from view to view.

    I have a product page in the CMS with no body which uses a layout of product, in the product layout its loading the viewfiles header | product view code | footer etc

    I would have a products view page where using the ID/URI Segment it would then query the database with the current product ID. Pretty simple stuff, the URI product will open up fine its just the URI thats failing me, when I navigate to anything past product/i.e a id number of which I need its returning 404.

    The page title once navigated to the URL is 404 Error : Page Cannot be found.

    <?

    // this is my product.php in _variables
    $pages['product|product/:num'] = array('view' => 'product');

    ?>

    Thanks
  • edited May 2012
    To your above reply I have no logic in the code that redirects to a 404, its happening before.

    also how im calling it

    http://www.website.co.uk/shop/index.php/product/2
  • edited 6:51AM
    I noticed from your URL that your site exists under the "shop" folder, could your 404 issue possibly be due to the .htaccess rewrite rule?
  • edited 6:51AM
    Tried that and doesn't seem to sort the issue :( could really do with getting this sorted arrggghhh lol it's driving me mad
  • edited 6:51AM
    Are there any settings in your routes.php config for that path?
  • edited 6:51AM
    Nothing just the default for fuel
  • edited 6:51AM
    FIXED! Silly me had the file in the _blocks. Thanks for your help
Sign In or Register to comment.