Store
Community Documentation

v3 Knowledgebase

Adding menu item under "Actions" drop-down menu under the Blog section

This tutorial will teach you how to add menu item under "Actions" drop-down menu under the Blog section (Blog module). After one clicked on the blog of choice, there is a drop-down "Actions" button under the blog title. By default, it has "Edit" and "Delete" menu links. We will be adding "Crate New Blog" menu link in there. This task will be accomplished using plugin, as editing source code is not recommended.

We will create a plugin in AdminCP (by going to AdminCP > Extensions > Plugin > Create New Plugin) that hooks to the following (in module Blog): blog.template_block_entry_links_main

Once you get to "Create Plugin" screen, fill out all required fields as in this example:

Product: Core
Module: Blog
Title: Add New Blog
Hook: blog.template_block_entry_links_main
Active: YES
PHP Code:
if (Phpfox::getUserParam('blog.add_new_blog'))
	{
		echo '<li><a href="' . Phpfox::getLib('url')->makeUrl('blog.add') . '">' . Phpfox::getPhrase('blog.add_new_blog') . '</a></li>';
	}


CLICK SAVE TO SAVE YOUR PLUGIN

DONE!

To check if it worked, go to "Blogs" and click on any blog title, then click on "Actions" button. You should see our newly created menu link "Add New Blog" right under/after "Delete".

NOTE 1: To created different menu items using this process, you have to make sure that you replace condition(s) in "if" statement with condition(s) relevant to your case (in this tutorial we wanted to make sure that only users with permissions to add new blog could do that, so we included "if (Phpfox::getUserParam('blog.add_new_blog'))" statement.

NOTE 2: When createing different menu items using this process, replace "blog.add" in "Phpfox::getLib('url')->makeUrl('blog.add')" with your target link (example: Phpfox::getLib('url')->makeUrl('blog.feature') ) and "blog.add_new_blog" in "Phpfox::getPhrase('blog.add_new_blog')" with the right phrase that is relevant to your case (example: Phpfox::getPhrase('blog.feature')).

NOTE 3: If target link you are using is not available in phpFox by default, you have to make sure you code it in before using it, as you will get "page not found" statement when trying to acces your link. If phrase you are using is not available by dafault, make sure you create it using "Ad Phrase" tool of phpFox, as your newly created link will not show up if phrase you are using is not available.

NOTE 4: You can add as many menu links as you like under "echo" statement. If links have different condition(s), you have to make sure that your links are placed inside of specific conditions, so only users that are allowed to have access to those links can use them (can see them) and not the others.

ADDITIONAL NOTE (for reference only): This plugin call ({plugin call='blog.template_block_entry_links_main'}) can be found in blog/template/block/link.html.php.

Please feel free to improve upon this tutorial.