like_to_code
-
Posts
3 -
Joined
-
Last visited
Posts posted by like_to_code
-
-
Thanks for the reply, it's good to know what I have been doing is ok.
I have organised things like this so far:
For example: Controllers/Backend/Home.php Controllers/Frontend/Home.php Models/Pagination.php Views/Backend/Admin/Home/index.php Views/Frontend/Home/index.php Core/Controller.php public/backend/css public/frontend/css public/index.php
In the Router.php dispatch method, where it matches the url, I added the following:
if (preg_match('/^(admin)/', $url)) { $this->setLocation('backend'); } else { $this->setLocation('frontend'); }
So if admin is mentioned at the start of the url, it sets the location to 'backend', which is then used in Router.php. It was the simplest solution I could think of.
$controller = $this->getLocation() . '\\' . $this->params['controller']; $controller = $this->convertToStudlyCaps($controller); $controller = $this->getNamespace() . $controller;
Things seem to be working ok and I have started adding features to the Frontend and Backend side of the CMS.
-
Hi, I am new here 🙂
I have been learning PHP and am currently working on my own OOP MVC CMS. I am up to the stage where I would like to start working on the admin area, but I am not sure how best to organise things.
Should I create admin specific Controllers and Models?
In Views, should I create a sub directory Admin, and place all admin view templates within it?
Are there any good books on OOP/MVC you would recommend?
OOP MVC AJAX CRUD MODAL
in PHP Coding Help
Posted
Hi, I am creating my first OOP MVC content management system.
I created a CRUD where on the Tag view page, you click edit and it takes you to the Tag edit page.
But I want to improve the user experience, so when a user clicks edit, a modal window displays allowing editing of Tag, upon clicking save, modal window closes and AJAX updates Tag view page without refresh.
You can see my Tag view.html here which is using Twig template system:
If I add a form in the modal window with {{ tag.id }} and {{ tag.name }}, nothing displays obviously because it is not in the for in loop. My question is, what is the industry standard way of getting data into this modal window form? I could use a $_GET["id"] but then I am breaking MVC model by including code in template. Is the solution to use JavaScript to get ID from edit link, in the background get data from database then use JavaScript to create form in modal?
Your help would be much appreciated!