Question On location and modules

edited April 2011 in Modules
I have gone through the tutorial on modules but I have a question or really am looking to be pointed in the right direction. Here is what I would like to do and would appreciate input. First of all the site I am working has pages setup through the admin. I have additional "pages" that are setup as a module like articles in the module tutorial. The reason I am doing this is because I need the ability to categorize etc. What I am trying to figure out is I have location setup on these module "pages" that I would like to able to have an address like http://somesite.com/article using that location if there is no page mapped to that location. Basically if no page maps to the address check to see if it maps to one of the articles setup in the module. Does this make sense? Do you have any thoughts?

Thanks in advance.

Comments

  • edited 6:02AM
    You may need to extend the fuel/modules/fuel/controllers/page_router.php file and then in your routes config file, change the 404_override page to your extended controller.
  • Ok I think that makes sense, so I would put the controller in the application's controller directory with code that looks like this?

    require_once(MODULES_PATH.'/fuel/controllers/page_router.php'); class Some_controller extends Page_router { function __construct() { parent::__construct(); } function _remap() { } }

    set the route to something like this

    $route['404_override'] = 'some_controller';

    any thing I should be aware or need to include ... this doesn't seem to be enough
  • edited 6:02AM
    I'm assuming you would put in your own code in the _remap method above correct?

    The only thing that I can think of that may not work correctly is navigating to the homepage because there is some code in Fuel_page and Fuel_pagevars that specifically looks for a value of 'page_router' and if it does exist, change it to the homepage (you can see where if you search for 'page_router'). You still may be OK though so I'd test it out and let me know. I've never needed to do this myself.
  • I am wondering if I am going about this wrong ... I am trying to create a directory of businesses for a portion of a site. Each business would have a page (http://www.address.com/business_name) which I can do easy enough with the page admin. Where I am having the break down is when I want to categorize the business pages by type or alphabetically on the front end of the web site. A business would map to multiple categories. Maybe I could create a multi select layout variable for categorization? It seems like extending the page router would be reinventing the wheel. Am I making this harder then it needs to be?
  • edited 6:02AM
    Possibly. I think you are on the right track with the multi select for categorization similar to the blog and categories. Passing the name of the category (as a slug or id), could generate a list of all the businesses under that category. No slug passed could present all of them in alphabetical order. Would that work for what you need?
Sign In or Register to comment.