0

can someone give me these examples to show an article or a block, page that already existing in a drupal website using pageshow or page_callback?

I currently can only successfully showing a link of the article, and then it lead me to the node. Here is my custom js code:

/**
 * Implements hook_menu()
 */
function intro_menu() {
  var items = {};
  items['intro'] = {
    title:'Introduction',
    page_callback: 'intro_page',
    pageshow: 'intro_page_pageshow'
  };
  return items;
}

function intro_page() {

 try{
  var content = {};
  content['my_stuff'] = {
    //markup: '<p>Nice stuff!</p>'
    theme: 'link',
    text: 'SlideShow',
    path: 'node/12'
  };
  return content;
 }
 catch (error) { console.log('intro_page - ' + error); }
}

function intro_page_pageshow() {
 // drupalgap_alert('My pageshow event has been called!');
}

After some trying, I can now do it with the following code:

    //page_callback
function intro_page() {
  return '<div id="my_node_3"></div>';
}


function intro_page_pageshow() {
 // drupalgap_alert('My pageshow event has been called!');
 try{
        var nid = 3;
        node_load(nid, {
        success:function(node){
         var content = node.content; 
         $('#' + 'my_node_' + nid).html(content).trigger('create');
          }
        });
  }
  catch (error) { console.log('intro_page_pageshow - ' + error); }
}

But it's just the content, not the whole node.

I am still trying to display a page of slide show... The problem is I cannot find the node id from a "page". I tried the "path", but it does not work.

1 Answer 1

0

If you want your app's front page to show a node, then you can just set the front page to that node, in settings.js:

drupalgap.settings.front = 'node/12';

Under the hood DrupalGap already has a page_callback (and pageshow) that can load and render all core entity types. As you noticed with nodes, you simply linke to node/[nid] to view a node.

As for blocks, DrupalGap does not interface with blocks stored in Drupal, instead DrupalGap can create its own blocks for display in the app: http://docs.drupalgap.org/7/Blocks

1
  • thank you. I already have done that, and successfully add a button in settings.js which will lead to the node.
    – artphys
    Jul 25, 2017 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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