Serve a static page using a single controller w/o making its own controller |
09-04-2016, 08:30 PM
(This post was last modified: 09-04-2016, 09:27 PM by 678238515702801. Edit Reason: Modified htaccess; added routes.php )
I have the following folder structure wherein inside the "views" folder I have several static pages organized by their "parent":
Code: my_project/ I have the following controller to serve all the views that are direct children of "pages". Code: <?php I have no problems linking to the top-level views under "pages" but when I traverse to a subfolder, it returns a 404. htaccess for reference: Code: <IfModule mod_rewrite.c> route.php PHP Code: $controller_views = 'pages/view'; What I want to achieve: From the folder structure above, I want to show "organization.php" and "history.php" through Pages::view() and calling them in my header as: Code: <a href='<?php echo base_url().'about/organization'; ?>'>Company Organzation</a> Current workaround: I made specific classes similar to Pages::view() for each of these subfolder views such as About::organization() and About::history(). I have no idea if I can serve subfolder static pages without resorting to the strict "controller/method" pattern but I hope you can help me with this. Currently there are no specific questions like mine online so I am looking forward to your advise.
Your default controller cannot include a sub-directory
So what you need is a single startup page before going to your pages controller, like Welcome or Home. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-05-2016, 04:28 AM)InsiteFX Wrote: Your default controller cannot include a sub-directory Apologies, I do not quite understand how this works. When viewing my project, it should first direct to a "single startup page"; from here all raw links will be directed to my static page service controller. What difference will this make? Or do you have a sample code on how to achieve this?
Most site today have what's called a landing page this is the first page on the web site from there just redirect to your page startup either through a button or continue link.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I am thankful for you noticing my problem @InsiteFX but as far as I know, the landing page is still served through my Pages::view() wherein the default parameter, as you can see in the Pages.php in my original post pertains to the name of my home page.
I just want to know if serving deep (at least a subfolder) view files within the views folder is possible without creating separate controller/method URIs for them just to abide by what I know CodeIgniter does. If anyone knows how to deal with this I am looking forward to your help. I am still 100% unsure if what I want is possible because all over the Internet the tutorials and questions so far do not dig deeper into serving static pages that are at most one subfolder deep from the views folder.
Read this Reserved Routes.
CodeIgniter Users Guide - URI Routing What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |