Create a website tutorial - Module page

edited April 2013 in Modules
Hi,

I follow the "Create a website tutorial" and everything is working as its written except one thing. I can't make the single item view page working.

Based on the tutorial, I create an "Ads" module.

On the view file, I can't find and show a single Ads_item.

Here is my code

$id = uri_segment(2); if (!empty($id)) { $ads_item = fuel_model('ads', array('find' => 'one', 'where' => array('id' => $id))); if (empty($ads_item)) show_404(); } else { $ads = fuel_model('ads'); }

Viewing all "Ads" is working, but single view of "Ads" from example.com/ads/1 is not.

Comments

  • edited 1:23PM
    Try running this after your code to see what query is being generated:
    $CI->ads_model->debug_query();
  • edited 1:23PM
    Where should I put the code? It keeps bring me 404 page.
  • edited 1:23PM
    right after your fuel_model code.
  • edited April 2013
    Still not working.

    It seems that /ads/1 doesn't reach the page. I put "exit()" code, it doesn't work either.

    /ads is working just fine. The "exit()" is working.

    I will restart the tutorial once more to see am I missing something.

    Thanks.
  • edited 1:23PM
    That sounds like you need to define the view for that URI path since that view file technically doesn't exist (views/ad does but views/ad/1 does not). To do that, add the following to your fuel/application/views/_variables/global.php file (or it could be in a ad.php variables file)
    $pages['ad/:any'] = array('view' => 'ad');
    Or you can set the fuel config parameter of "auto_search_views" = TRUE.
  • edited 1:23PM
    Thanks it is working now :D
Sign In or Register to comment.