I’m completely new to WPMVC. Followed and finished their tutorial for creating plugins. Now I’m trying to add a search page to search Venues
(that comes from their example!). This page should appear as a submenu page of the Venues
menu. I created a file named search.php
in the app/views/admin/venue/search
folder. What should I do now? Googling didn’t help much!
Any help regarding this (and any other stuff a noob should learn to get better with WPMVC) is welcome!
Finally after a lot of digging into the core files, I found the way to add a
submenu
page. Here’s the stepwise solution if anyone is stuck on it!Lets assume you want to add a submenu page called ‘Sample’.
1.First, in the
app/config/bootstrap.php
file (you have to manually create it if it doesn’t exist) of your plugin, add the following code. This will add the new page as asubmenu
of thevenues
parent menu item:2.Next, in the
app/controllers/admin/admin_venues_controller.php
add the following function. Notice it is namedsample
, same as the page name in the array above.3.Now the actual page content file, create a
sample.php
(notice the name) file in theapp/views/admin/venues/
folder.That’s pretty much it! I’m still stuck on creating a top level menu page without having to create a model (models get top level pages by default). Will update this answer when I solve it!
Note: Emailing Tom Benner, the creator of WPMVC didn’t help too! 😉
Add an action hook in your plugin main file
plugin_name.php
, giving the details of the menu. You can have an admin menu, of course, without generating a model.Here is the code for
/plugins/my-plugin/my_plugin.php
You can leave the image location empty to use a default WordPress icon for the custom menu.
Of course, you can add submenus in the same way, or using
bootstrap.php
as well.In the picture below, I have added ‘My Menu’ by this method.