Hi! I was wondering what are the steps needed to create a custom dispatch location other than just specifying it in the dispatch option in layout settings. Only doing that results in a 404 message appearing when going to that dispatch URL. Thank you!
Hello
All you need is to create 2 files. For example:
1. Controller
app/addons/my_changes/controllers/frontend/my_controller.php
2. Template
design/themes/responsive/templates/addons/my_changes/views/my_controller/view.tpl
Hi! Thank you for the answers. Will look into how these files are made :)
Hello, I've been able to create and display the files on the frontend side by placing them on the directed paths above but failed to do so in the admin/backend side of the website.
I've tried placing the same files on the backend folder of both views and controllers but it still just leads to a 404 page. Does fn_dispatch treat backend files differently? The page I transferred was purely purely text from the database.
Thanks.
It should work for the backend too
1. Controller
app/addons/my_changes/controllers/backend/my_controller.php
2. Template
design/backend/templates/addons/my_changes/views/my_controller/update.tpl
Ah I see, made the mistake of putting the controller directly on the backend folder in controllers instead of in addons.
Thanks!
Hi, I'm trying to understand how dispatches work in order to make my own custom one.
Right now I have a php controller file in
app/addons/my_changes/frontend/
and put a .tpl file in
design/themes/responsive/templates/addons/my_changes/views//view.tpl
From what I understand, depending on the value of $mode in the php file, it will run a particular run of code that will retrieve certain information and then pass along that information as Smarty variables for the .tpl file to use. Is that correct?
The contents of the php controller file and template file that I mentioned before are pretty much empty, I just want to display any text to start out. The php file almost has nothing in it, while the .tpl file literally only has "This is where the custom dispatch goes"
That worked, the next step I tried was to change the filename of view.tpl to 'add.tpl', and then put a block of code in the controller
(if $mode == 'add') {
}
with nothing inside the if block.
I tried going to the url /index.php?dispatch=.add but then it just 404s, whereas when the .tpl file was named view.tpl the page displayed the text I put in it.
Can anyone help me understand why that's happening, and what I'm doing wrong?
This is undocumented feature. For all add modes the system loads update.tpl file. It is done to exclude duplicated files for add and update actions.
Oh wow, it worked. Weird that it's undocumented. Anyway, thanks!
You are welcome!