I have installed the faq and faq_ask module.
The faq_ask module adds a navigation link of 'ask a question'.
When I click on it, it displays a form to the user to ask a question.
The faq module adds a navigation link of frequently asked questions.
When I click on it, it displays the questions and answers list. It contains two tabs 'list' and 'order'.
I have added the third tab of 'ask a question' and Now I want to display the ask a question form on this tab.
EDIT:
function test_menu() {
$items = array();
$items['faq/ask_question'] =array(
'title' => 'Ask a question',
'page callback' => 'drupal_get_form',
'page arguments' => array("test_ask_question"),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
Any Idea about this???
Related
I want to change OctoberCMS backend menu organization.
Example:
I want to move from sidebar of Rainlab Plugin Static Pages - Menus to OctoberCMS CMS SideBar or it can be possible to add Rainlab Plugin Static Pages - Menus to main menu.
You can do this in your plugin.php file with registerNavigation function. For example this code define top menu and sidebar menu:
return [
'title' => [
'label' => 'title',
'url' => Backend::url('...'),
'icon' => 'icon-cube',
'permissions' => ['access.*'],
'order' => 501,
'sideMenu' => [
'title' => [
'label' => '....',
'url' => Backend::url('....'),
'icon' => 'icon-slack',
'permissions' => ['access'],
'order' => 500,
],
Also in your controller you must define this:
BackendMenu::setContext('Author.Plugin Name', 'plugin', 'model');
I know this might be really obvious but I'll still say it just to be sure. If you are looking at changing the appearance or location of Backend Menu Items provided by plugins you did not author, don't make any changes to those files yourself. You would just loose all such custom changes everytime you update that plugin.
A better idea would be to create your own plugin that uses the 3rd-party plugin as a dependency and then make required changes to this new plugin.
Example Case: You wish to alter the display of the RainLab.User plugin backend menu item.
Create a new plugin and name it as needed. For ex: Acme.UserExtension.
Now in the plugin.php file of this new plugin you can add a dependency on the RainLab.User plugin and then hide it's menu item like so:
public $require = ['RainLab.User'];
public function boot()
{
/** Add a side-menu item */
Event::listen('backend.menu.extendItems', function($manager) {
$manager->addSideMenuItem('RainLab.User', 'user', [
'payments' => [
'label' => '...'
]
]);
});
/** Add a custom main-menu item */
Event::listen('backend.menu.extendItems', function($manager) {
$manager->addMainMenuItem('Acme.UserExtension', 'user');
});
/** Remove the original main-menu item */
Event::listen('backend.menu.extendItems', function($manager) {
$manager->removeMainMenuItem('RainLab.User', 'user');
});
}
As you can see you can completely remove a menu item for a plugin you dont own if you want. You could just extend it like shown above and just use the registerNavigation() method to do what you need for this extension plugin. You might have to replicate some of the menu items you do want to retain from the original parent plugin but now you have the ability to add some of your own or remove the items you don't need.
More details on how you can do this are here -> http://octobercms.com/docs/plugin/extending#extending-backend-menu
Hopefully this isn't too convoluted and helps you out.
While extending standard October backend controllers is very easy and described in documentation (mentioned in answers above), manipulations with Static Pages by RainLab are more complicated as "side navigation" (tabs) is handled with JavaScript. It's not possible to add a new item to this plugin navigation through the methods from the October CMS docs or to add "menu" sidemenu item to another plugin. With standard extend it's possible to show only one tab (you were asking about menu) but this won't set it as default and "pages" will still be shown as default.
If you are using only Static Menu my solution is to rename top menu Pages -> Menus and hide all tabs except "menu" with permissions (they will still be visible for admin but at least won't confuse backend editor). Will be happy if someone will share a better solution.
The code to place in your custom plugin, in boot() + don't forget to set permissions while creating a backend user for the client.
// Rename rainlab.menu pages to menu
Event::listen('backend.menu.extendItems', function($manager)
{
$manager->addMainMenuItems('RainLab.Pages', [
'pages' => [
'label' => 'Menu',
'url' => Backend::url('rainlab/pages'),
'icon' => 'icon-align-justify',
'sideMenu' => [
'menus' => [
'label' => 'rainlab.pages::lang.menu.menu_label',
'icon' => 'icon-sitemap',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'menus'],
'permissions' => ['rainlab.pages.manage_menus']
],
]
],
]);
});
I previously wrote this question Stacking of Context Menus in Electron and created this issue in the context menu module for electron.
Even though my question above is quite detailed, it got no replies. Then, #sindresorhus recommended I ask this question on StackOverflow:
How do I de-register context menu's in electron? I have a program in which, depending on where you click, a different context menu will show up:
handleContextMenu() {
this.props.contextMenu({
prepend: (params, browserWindow) => [{
label: `Summary ${this.state.msn}`,
click: () => this.createSummary()
},{
label: `Library Compare ${this.state.msn}`,
click: () => this.runLibCompare()
},{
label: `Visualize ${this.state.msn}`,
click: () => dialog.showMessageBox({
type: 'question',
buttons: this.vizButtons,
defaultId: 0,
title: `Choose your visualization`,
message: `Choose your visualization for ${this.state.msn}.`,
}, res => this.visualize(res))
}]
});
};
However, when I right-click on another area, the first context menu pops up, then the second, all the way till the current context menu shows up.
I basically want to de-register a context menu after it has been dismissed. How do I do that?
Update:
Got rid of the context menu and simply fed this to handleContextMenu function:
handleContextMenu = menuItems => {
const menu = new electron.remote.Menu();
menu.append(new electron.remote.MenuItem(menuItems));
menu.popup(electron.remote.getCurrentWindow());
}
And it works! That's that, got rid of the electron-context-menu as well.
This is possible with standard Electron Menu API without additional modules, perhaps using electron-context-menu is just complicating things since that seems to be designed to simplify things for the specific use-case of a standard context menu. With the standard Menu API, you can create and pop-up a menu on each click, so there is no need to "de-register" a menu.
Here's a simplified example, creating a different new context menu with each click:
let menuCount = 1;
window.addEventListener('contextmenu', (e) => {
e.preventDefault();
let menu = new electron.remote.Menu();
menu.append(new electron.remote.MenuItem({label : "Context Menu "+menuCount++}))
menu.popup(electron.remote.getCurrentWindow());
});
On the first right-click you will see a menu with an item "Context Menu 1", on the second right-click, "Context Menu 2", and so on.
For SEO purposes I need to remove the first page number from the URL. i.e I have the following:
example.com/pages/view/1 and example.com/pages/view the two URLs points to the same contents of the view action. I want to make the pagination free from 1 in the URL. i.e first Page link and Page Number 1 should be linked to pages/view.
I tried to deal with the $pagination object like the following:
$pages = new Pagination(['totalCount' => $books['booksCount'], 'pageParam' => 'start', 'defaultPageSize' => 10,]);
$pagingLinks = $pages->getLinks();
$pagingLinks['first'] = '/';
$pages->links = $pagingLinks;
However, the last line causing error:
Setting read-only property: yii\data\Pagination::links
So I have a problem to modify the links property. Is there any other solution to get this task done?!
According to docs you should set yii\data\Pagination::forcePageParam to false by passing it in Pagination constructor
$pages = new Pagination([
'totalCount' => $books['booksCount'],
'pageParam' => 'start',
'defaultPageSize' => 10,
'forcePageParam' => false,
]);
The above answer may works for direct use of Pagination but remain an issue if it was used from another widget such as ListView.
I found the solution from a comment on an issue report on Yii2 repository on github
The solution is just define proper route in config/web.php. Suppose here we have a controller called Suras and we use the ListView widget on its action's view called view. So placing rule array with defaults has value 'page' => 1 will prevent adding the page parameter to the link's URL of the first page. Also notice the first rule 'view/<id:\d+>/1' => 'Error404', is placed in-order to prevent any access to the first page using page=1 parameter, for example, trying to access mysite.com/view/20/1 will invoke 404 error, because there is no controller called Error404.
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'view/<id:\d+>/1' => 'Error404',
['pattern' => 'view/<id:\d+>/<page:\d+>', 'route' => 'suras/view', 'defaults' => ['page' => 1]],
'view/<id:\d+>/<page:\d+>' => 'suras/view',
'view/<id:\d+>' => 'suras/view',
],
],
],
When the user gets a user password reset link like this password reset like this http://digitalsuite.unitedway.org/user/reset/3/1356108765/5ff18af572734c897f4d7a2946983a87
it doesnt automatically log them in , they get no message, just goes to the login screen right away.
Where is this coded so I can debug what is happening?
thanks
Diana
When trying to figure out where to start debugging in Drupal, it generally helps to take a look at the hook_menu implementation that defines the page in question. Hook_menu "…enables modules to register paths in order to define how URL requests are handled."
In this case, the user module's user_menu function, is defined in the user.module file.
$items['user/reset/%/%/%'] = array(
'title' => 'Reset password',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_pass_reset', 2, 3, 4),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'user.pages.inc',
);
Notice that 'page arguments' points to 'user_pass_reset', which is located in the user.pages.inc file. That would be a good place to start debugging.
I have built a non-node module and I wish to integrate it with Open Atrium as a feature.
I've experimented with a test feature to try "crack the code" of features, spaces, and open atrium, as the documentation does not cover this topic and I'm new to features, spaces, and open atrium.
I created a feature using features and then customised the info and module files.
Info file:
core = "6.x"
description = "A test feature"
name = "Test Feature"
package = "Features"
spaces[types][] = "og"
features[][] = ""code here
Module file:
function test_feature_menu()
{
$items['ftest'] = array(
'title' => 'Test Feature',
'page callback' => 'test_feature_page',
'access callback' => 'spaces_menu_access',
'type' => MENU_NORMAL_ITEM,
'menu_name' => 'features'
);
}
function test_feature_page()
{
$output = 'test';
return $output;
}
The feature appears in the features section, and when enabled, appears in the features menu regardless of what group I am in. Further, the groups have the feature set as disabled, but the item still appears in the menu.
Can anyone shed some light on this?
Thanks,
Greg.
Ok, I figured it out:
The access callback should be 'spaces_access_feature', and the access arguments should be array('view', 'test_feature');