DrupalGap icon indicating copy to clipboard operation
DrupalGap copied to clipboard

Adding markup below the Node content

Open SegaWeb opened this issue 6 years ago • 3 comments

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?

SegaWeb avatar Jun 27 '18 07:06 SegaWeb

@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

signalpoint avatar Jun 27 '18 13:06 signalpoint

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 avatar Jun 28 '18 06:06 SegaWeb

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

SegaWeb avatar Jul 04 '18 06:07 SegaWeb