Question

I put a navbar in the footer and placed some buttons. The display is good, but I cannot find a way to assign the link to a button like usual. The node/123 in the does not work.

/**
 * 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 content = {};
  var content = '<div data-role="navbar">';
  content += '<ul>';
  content += '<li><a href="" data-icon="home">Home</a></li>';
  content += '<li><a href="node/1029" data-icon="action">Saved</a></li>';
  content += '<li><a href="node/969" data-icon="star">Sponsors</a></li>';
  content += '<li><a href="node/1021" data-icon="gear">Setup</a></li>';
  content += '</ul></div>';
  if (delta == 'footer_intrfc_block') {
    content['my_out'] = {
      markup: ''
    };
  }
  return content;
}

enter image description here

The link of node will show "Error Loading Page". I wonder where I can set my link by path: 'node/123' like in setting.js

I also tried:

content += '<li><a onclick="javascript:drupalgap_goto("node/1029");" data-icon="action">Saved</a></li>';

and

content += '<li><a href="javascript:drupalgap_goto("node/1029");" data-icon="action">Saved</a></li>';

but they do not work.

Was it helpful?

Solution

Try this in your hook_block_view():

var content = '<div data-role="navbar">';
content += theme('item_list', {
  items: [
    l('Home', '', { attributes: { 'data-icon': 'home' } }),
    l('Saved', 'node/1029', { attributes: { 'data-icon': 'action' } }),
    l('Sponsors', 'node/969', { attributes: { 'data-icon': 'star' } }),
    l('Setup', 'node/1021', { attributes: { 'data-icon': 'gear' } })
  ]
});
content += '</div>';
return content;

Whenever linking in DrupalGap, the key is to use the l() or bl() functions which will properly assemble a link or button link for you. Here's the docs page with more info: http://docs.drupalgap.org/7/Pages/Navigating_Pages

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top