how do I know which link has been clicked on web page? - CI newbie Q |
[eluser]charlie spider[/eluser]
Hi Brian, you might like the solution I use. I snaged this little bit of code from an Elliot Haughin tutorial ( www.haughin.com/ ) that allows me to route all requests for webpages that don't have a corresponding controller/method to one catch-all controller. This allows me to have dedicated controllers for specific things and then one for all of the regular generic pages of a website. In fact I only use specific controllers for the admin section of my sites. All of the public pages go to a controller called "pages". Once I hit that controller I can pull the relevent page info from the database, load whatever resources, content, templates, etc, that are required, and serve the page. Here's the routing code: Code: $exclude = array ( '.', '..', 'index.html', 'pages.php' ); So this code builds an array of all of the "other" controllers in your application/controllers directory so that requests for them can be met, and then routes everything else to "pages" via a wildcard. Since all of my public pages go to the one controller, and I don't use any other methods for that controller, I can simply grab the last segment of the uri to find out what page is being requested, like this: Code: $current_page = $this->uri->segment_array( $this->uri->total_segments() ); whether a page is a subpage (or a subpage of a subpage) is set in the database, and I just build the full url for navigation links, but basically I only ever care what the last segment of the uri is. This allows me to dynamically add as many pages as I want anywhere in the sitemap tree without having to create a new controller for each page. On the admin side of things I basically do what WanWizard talked about. Specific controllers with multiple methods logically grouped together based on functionality. So I use the typical CI one-to-one webpage-to-controller/method system for my admin side of things but wildcard routing for the public pages. Hope that helps you out. |
Messages In This Thread |
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 01:53 AM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 03:24 AM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 07:25 AM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 08:33 AM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 11:17 AM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 04:29 PM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-25-2010, 11:13 PM
how do I know which link has been clicked on web page? - CI newbie Q - by El Forum - 06-26-2010, 02:29 AM
|