Closed (fixed)
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Core integration
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2013 at 14:12 UTC
Updated:
29 Nov 2013 at 17:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
drunken monkeyYes, you are correct, at least I don't know of a way to currently do that. Also, this part is implemented in the Entity API, so any changes (or custom hooking) would have to be done there.
If you want to go the custom route, just adding a "child" property to nodes via
hook_entity_property_info_alter()should work.Comment #2
Bojhan commentedSo I guess this would then be a feature request. I am not sure I am able to make a custom route element.
Comment #3
drunken monkeyComment #5
nick_vhYou could add this to the indexing logic when indexing books as custom
code, or when identifying if the entity is a book. Since book is a D7
core module you should support it right? ;-)
Some quick thoughts on how :
Comment #6
drunken monkeyHere is the implementation of the property, adding a list of all book ancestors.
This will then be available in Search API views displaying nodes as "Indexed node: Book ancestors", where you can just display them as a concatenation of labels.
Comment #8
drunken monkeyThis one should work, also updating the tests.
Comment #9
drunken monkey(Couldn't test myself, as running a test takes more than ten minutes, apparently, on this laptop.)
Comment #11
Bojhan commentedLet me know if there is something I can help with, testing or so.
Comment #12
drunken monkeyWell, once the automated tests pass it would of course be great if you could verify that the new functionality is working correctly.
Comment #13
Bojhan commentedOk I tested it, and it worked! Whoo :)
I did get a debug message, but that might be because I checked out entity and just applied the patch.
Comment #14
klausifiles should end in a single new line.
debug statement
debug statement.
are you sure that you need to load the nodes? Shouldn't we be able to return just an array of IDs and the wrappers will take care of loading if needed?
here too.
Comment #15
Bojhan commentedFixed debug and newline. Not sure how useful this patch actually is, hah :D. Just keen on moving it forward.
Don't know what to do with the array of ID's or nodes.
Comment #16
Bojhan commentedComment #17
drunken monkeyOops! Sorry about the debug statements (it was really hard to find out what the hell was going on), and thanks to Bojhan for fixing them!
I know – that's why I added one in my patch. :P
Attached is the exact same patch as in #15, but with that newline re-added.
We do return just an array of NIDs. However, we need to load the node to get it's book information.
Comment #18
fagoWe should clarify somewhere what book ancestors are, i.e. all book pages up in the book hierarchy, or so? I cannot think of more precise name instead of "book ancestors" but at least the description should me tell that.
Is there no more efficient way to do that? Looks like it will become slow if used for multiple nodes...
Else, patch looks good to me.
Comment #19
Bojhan commentedWhat about "Lists all books upwards in the book hierarchy"
Comment #20
fagoI'm not sure about book vs book page. Is "book" and "book page" the same, or does "book" just refer to the root of a book?
Else, the suggestion sounds good to me.
Comment #21
Bojhan commentedI guess it refers to the latter, the root of the block?
Comment #22
drunken monkeyThe description now reads as follows:
Hm, yes, I guess so …
There's no "clean" way (i.e., using the API) of doing it, I think, but we could of course use the database tables directly, from
{menu_links}'sp*columns we should be able to read the whole hierarchy in one go. Then one query to look up the associated NIDs from{book}and we'd be done.If such lower-level operations are OK, we could also use that.
Comment #23
Bojhan commentedI think the description is fine, I hope @fago or @klausi can review it and mark it RTBC. I am hoping to use this in my project soon :)
Comment #24
Bojhan commentedI am going to mark this RTBC, seems like tests pass and review is matched
Comment #25
fagoIf necessary, yeah. Let's see whether this becomes problematic and improve it if so.
Committed, thanks.
Comment #26
Bojhan commentedJust wondering, in what release will I find this? Is this in dev or is this in a point release? (if so, when will the point release be out?)