Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Create entirely new Controller
CnControllER
New
Hello, I'm newbie to vanilla forums
but I'm trying to understand the concept of the controllers. For example: http://vanillaforums/ajax/ ...
Is it possible to create a new one? If yes, how?
I'm having a custom theme. I have to create a folder: controllers in it? And add the new controller .php file in it?
Or I have to create a "virtual controller", using magic methods in a custom plugin, as described here: http://docs.vanillaforums.com/developers/plugins/
Thanks in advance!
Tagged:
0
Comments
Basically, when you create a
public function PluginController_Something_Create($Sender, $Args) {}
, that method can be reached as "yourforum.com/plugin/something/argument1/argument2" and $Args holds array(argument1, argument2).If you like to access that method under yourforum.com/fancyname you have to create a custom route.
You can see how all this is done here: http://vanillaforums.org/addon/howtovanillapage-plugin
personally I prefer to extend the
vanillaController
you wouldn't typically have a controller just for ajax, the concept of controller method is they could return a range of deliver type and methods.
If you set
->Data
that could be used for json. Having said that I have implemented these methods a number of ways.grep is your friend.
I want to tack on and say you could extend the rootController and dispatch from there.
This has the added benefit of not requiring a custom route to be at the "top level".
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
That part of the question hasn't been answered yet...
Create a file called
class.yourthemenamethemehooks.php
like that:For my code to work, you would have to use:
Or write your own dispatch method.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Note that you need to initialize the HeadModule yourself when using the rootController:
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Oh, how many have become bald due to scratching their head about
sweetNothing
Surely there is something to be put in its place, no?
You will need "create" instead of "handler"
I have this but no dice, I suspect it is because it is a themehook ...
I am missing something basic.
Not sure how to really test if it is working
Aha, I found some info that is very promising that I am going to play with.
\vanilla-3.2\applications\dashboard\controllers\class.rootcontroller.php
Confirmed!
Does not work from a themehook, for a strange reason. But works in a plugin nicely.
For another person, my code is
Accessed via
example.com/forum/newboss
My plan is to set this as route destination for specified Discussions and do some imaginative rerouting for some super efficient clean urls