2

I do not need the profile view tab and would like to link from a menu directly to user/%/edit/. In settings.js below I tried different paths, none of which worked.

// User Menu Authenticated
drupalgap.settings.menus['user_menu_authenticated'] = {
 options: menu_popup_get_default_options(),
 links: [
{
  title: 'My Account',
  path: 'user',
  path: 'user/%/edit', //not working
  path: 'user/edit', // not working
  options: {
    attributes: {
      'data-icon': 'user',
      'class': 'ui-btn ui-btn-icon-right'
    }
  }
},

Is there a (simple) way to set such a direct link?

3

When the settings.js file is loaded in DrupalGap, the framework isn't yet aware of who the current user is, so it is not possible to place this type of dynamic link into traditional DrupalGap menus. Instead you can use a block to simulate a dynamic menu.

http://docs.drupalgap.org/7/Menus/Menus_with_Dynamic_Links

/**
 * Implements hook_block_info().
 */
function my_module_block_info() {
  try {
    var blocks = {};
    blocks['my_module_user_menu'] = {
      delta: 'my_module_user_menu',
      module: 'my_module'
    }
    return blocks;
  }
  catch (error) { console.log('my_module_block_info - ' + error); }
}

/**
 * Implements hook_block_view().
 */
function my_module_block_view(delta, region) {
  try {
    var content = '';
    switch (delta) {
      case 'my_module_user_menu':
        var uid = Drupal.user.uid;
        var html = theme('popup', {
            content: theme('jqm_item_list', {
                items: [
                  l('View profile', 'user'),
                  l('Edit account', 'user/' + uid + '/edit'),
                  l('Logout', 'user/logout')
                ]
            }),
            attributes: {
              id: drupalgap_get_page_id() + '_my_module_user_menu'
            },
            button_attributes: {
              'data-icon': 'bars',
              'data-iconpos': 'notext',
              'class': 'ui-btn-left'
            }
        });
        return html;
        break;
    }
    return content;
  }
  catch (error) { console.log('my_module_block_view - ' + error); }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.