How to link a custom menu to a custom button in drupalgap?
-
04-01-2021 - |
Question
I would like to put the pop-up main_menu written in the setting.js
to my custom button. It seems that the path name I use is not correct.
l('Menu', 'main_menu', { attributes: { 'data-icon': 'star' } })
I also tried this and does not successful. The second parameter in l( )
link path is needed.
l('Menu', { attributes: { 'data-icon': 'star' }, popup: true, popup_delta: 'main_menu' })
So, what is the correct path name of the main_menu? or how do I link my custom menu to my custom button or link?
This is how I do my custom popup button:
var btn_setup = theme('popup', {
content: theme('jqm_item_list', {
items: [
l('View profile', 'user'),
l('Login', 'user/login'),
l('Logout', 'user/logout')
]
}),
button_text: 'Setup',
button_attributes: {
'data-icon': 'gear'
}
});
It does not popup anthing, even I just put a simple content, such as:
content:'<p>This is a test</p>'
nothing happen when clicking the button.
After several experiments, the popup function needs to set the page id.
var btn_setup = theme('popup', {
content: theme('jqm_item_list', {
items: [
l('View profile', 'user'),
l('Login', 'user/login'),
l('Logout', 'user/logout')
]
}),
attributes: {
id: drupalgap_get_page_id() + '_this_page_hook'
},
button_text: 'Setup',
button_attributes: {
'data-icon': 'gear'
}
});
So the question is, when I put this button in the header or footer, I want it display in any page. How do I set the page id for any page?
Solution
When put in the header or footer block, just give the page id the block name. Here is the code:
/**
* Implements hook_block_info().
*/
function footer_intrfc_block_info() {
var blocks = {};
blocks['footer_intrfc_block'] = {
delta: 'footer_intrfc_block',
module: 'footer_intrfc'
};
return blocks;
}
/**
* Implements hook_block_view().
*/
function footer_intrfc_block_view(delta, region) {
var html = '<div>';
var btn_setup = theme('popup', {
content: theme('jqm_item_list', {
items: [
l('View profile', 'user'),
l('Login', 'user/login'),
l('Logout', 'user/logout')
]
}),
attributes: {
id: drupalgap_get_page_id() + '_footer_intrfc_block'
},
button_text: 'Setup',
button_attributes: {
'data-icon': 'gear'
}
});
html += btn_setup + '</div>';
return html
}