signalpoint / DrupalGap

An application development kit for Drupal websites.
https://www.drupalgap.org
GNU General Public License v2.0
232 stars 185 forks source link

Adding markup below the Node content #1023

Open SegaWeb opened 5 years ago

SegaWeb commented 5 years ago

I just need to add a link under the content of the node. I'm using hook_node_page_view_alter_TYPE().

How can I make a standard node render inside this hook? In the manual I found only custom rendering, but I need to leave all the markup, language settings, etc.

Or maybe there is a better way to solve my problem?

signalpoint commented 5 years ago

@SegaWeb There are a few more hooks you can try listed here:

https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/api/api.js

Try some of the hook_entity_* ones, this one looks promising: https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/api/api.js#L311

SegaWeb commented 5 years ago

Yes, that would be better. But, build['foo'] does not display anything. Console.log works as expected.

function s_module_entity_view_alter(entity_type, entity_id, mode, build) {
  try {
    if (entity_type == 'node' && mode == 'view' && build.node.type == 'site') {
        build['foo'] = { markup: '<p>Extra stuff when viewing own user profile...</p>' };

        console.log(entity_type);
        console.log(entity_id);
        console.log(mode);
        console.log(build);
    }
  }
  catch (error) { console.log('hook_entity_view_alter - ' + error); }
}

Am I doing something wrong? Or the hook does not work?

SegaWeb commented 5 years ago

Does anyone use hook_entity_view_alter, only it does not work for me? I really need to know