I'm having trouble following the MVC standard. |
I'm new to CodeIgniter and I may have made a silly mistake. I have a view called "menu.php" with several options, such as "Query" and "Registration". When I click on "Query", it should call the view "queryProducts.php", but it's not working. How can I call it from the menu? It worked fine without the framework, but I'm having omegle voojio shagle trouble following the MVC standard.
(03-09-2023, 02:47 AM)LieoUhlerredyh Wrote: I'm new to CodeIgniter and I may have made a silly mistake. I have a view called "menu.php" with several options, such as "Query" and "Registration". When I click on "Query", it should call the view "queryProducts.php", but it's not working. How can I call it from the menu? It worked fine without the framework, but I'm having trouble following the MVC standard. Hi You can do if you following. In you controller you should have different methods for each view: PHP Code: // Assume this is your default view and the route is /home I have assumed you would have the following view files in your Views folder: - header.php - footer.php - menu.php - queryProducts.php - register.php - somepage.php I assume you can create links in your view file using site_url() as described here: https://codeigniter4.github.io/CodeIgnit...elper.html Also please read: https://codeigniter4.github.io/CodeIgnit...pages.html
i do mostly everthing from routes .So suppose on dev localhost , I have a view displaying : http://127.0.0.7/blogArticle/Southhall-Church-Park
via Code: <a href = blogArticle/Southhall-Church-Park> Southhall-Church-Park </a> blogArticle is connected to a route and Southhall-Church-Park is a slug I have in a slug field of slug in app/config/Routes.php i have : Code: $routes->get('blogArticle/(:segment)', 'Blog::showArticle/$1'); so in the above anything in a url with blogArticle is going to get picked up whats on the left i.e the url section is going to get passed to a controller called Blog.php and processes in a function as follows Code: Blog::showArticle/$1 Code: public function showArticle($theSlug) So you can design how menu or a href links in views are handled |
Welcome Guest, Not a member yet? Register Sign In |