Drupal 7 hook_node_view for book node? - drupal-7

I'm trying to modify the contents of any book node in a drupal 7 module.
I've tried hook_node_view, hook_node_view_alter, and hook_entity_view
and nothing get's invoked for book nodes. Basic page nodes call them all.
Clearly, I'm missing some basic drupalism here. Are books not really nodes?
Is there some other hook to call?

Looks like the hook_entity_load is invoked by book nodes. Would be nice to know more if somebody has a better answer/explanation as to what's going on here.

Related

Is there a way to have a function where given some arguments, it returns state and/or actions?

I am currently building a simple web element editor with React using Redux. It works as it should work with a small number of elements. I can see though that when the number of elements gets on a two digit scale, it will be frustrating to organize and maintain. The reason is because I have to pass [IDs and names (local to the function data), State, Actions] to the function I call which in turn filters the arguments and calls other functions with the right arguments etc. I think it is more ifs than it is needed. Can it be done with a function where I can have all the state and the actions, pass it some arguments, choose the correct path and done?
I do not think that providing code will help with this question, you would have see my file system as well to have the whole picture.
I am a junior developer so please forgive me if this is a stupid question or similar. Thank you in advance!

Equivalent to `onEndReached` for React

I'm trying to implement an infinite list for a React project and I'd like to know if there is an equivalent to the onEndReached from react-native that I could use to get this done easily. The idea would be to have an offset and a limit in my request so that I can append a batch of elements after I reached the end of my list.
I haven't found many options except some already complete components but I do need to implement mine.
I also found this question from January 27 (How can I implement a robust onEndReached for ScrollView on React Native) but since he doesn't have any answer I thought I should ask here.
Do you guys have any idea ?
Thanks in advance
By quick Googling, this can detect when you scroll to an element. It can call your callback to fetch more items.
https://github.com/brigade/react-waypoint

Setup for enhancing the C language using mbeddr and mps

I'm trying to write some new statements for an internal C DSL.
The tool of my choice is MPS and the base is the c-core of mbeddr.
I found this tutorial on the internet. Since it is a little old, I am not able to duplicate the exact structure of the setup itself.
What I want to do is to create a new language. This language must be extended by com.mbeddr.core. I found, how to extend the language and did so. I needed to extend every single language com.mbeddr.core.* by its own, everything else did not work (it does not even work properly now).
The I created a new statement in a structure module. There I extended the concept to a Statement (c.m.c.statements.structure is shown). Then, following the video tutorial, I wanted to add an expression as a child, this is where it fails.
I am not sure where I went wrong here. It is very difficult to set it up properly, since all tutorials/guides are outdated.
Thanks for your help,
Best Simon

Database moddelling - Trying to understand

Hey guys, I always get confused by this so it's not exactly my strong point :( Am I understanding correctly that the above example suggests:
One shop must have one or more clients
One client must have one shop
If there was to be a circle where at the end of the client arrow it suggests that the shop has zero or many clients.
I know it's a bad example but I am just trying to get my head around it. (Always get it the wrong way round)
Thanks very much, all help appreciated.
it's just a quick example so I apologise for the bad naming convention of table names
Yes, you are understanding correctly.

Cakephp associations custom methods

I was wondering the following, if I have these two Models:
Author
Book
And every author has written a few books, together with some other authors.
So basically every book has:
Title
MainAuthor
CoAuthor
Now in my application I need to check a lot if a Auther is either a MainAuthor or a CoAuthor. My idea was to create a method in the Author model to check this.
So basically, I can do something like this:
$this->Author->hasWritten($bookId)
However, I was wondering, what do you think of this approuch, and how would you do this?
It seems correcto to me to do that, but I think a Book could has two main Authors or maybe more, and other many more CoAuthors.
In your explanation, I understood that one Book only have one MainAuthor and one CoAuthor. If that is realy the system it's fine like you describe, but If it's like I write you have to think in creating an Help table.

Resources