Provide the Book Ancestors views field from Entity API on D7
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3535340. --> Reported by: [damienmckenna](https://www.drupal.org/user/108450) Related to !120 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The Entity API module provided a property/field called "book_ancestors" with this code:</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ancestors </span><span style="color: #007700">= array();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!empty(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book</span><span style="color: #007700">[</span><span style="color: #DD0000">'plid'</span><span style="color: #007700">]) &amp;&amp; </span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book</span><span style="color: #007700">[</span><span style="color: #DD0000">'plid'</span><span style="color: #007700">] != -</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$link </span><span style="color: #007700">= </span><span style="color: #0000BB">book_link_load</span><span style="color: #007700">(</span><span style="color: #0000BB">$node</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book</span><span style="color: #007700">[</span><span style="color: #DD0000">'plid'</span><span style="color: #007700">]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">array_unshift</span><span style="color: #007700">(</span><span style="color: #0000BB">$ancestors</span><span style="color: #007700">, </span><span style="color: #0000BB">$link</span><span style="color: #007700">[</span><span style="color: #DD0000">'nid'</span><span style="color: #007700">]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$node </span><span style="color: #007700">= </span><span style="color: #0000BB">node_load</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">[</span><span style="color: #DD0000">'nid'</span><span style="color: #007700">]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">$ancestors</span><span style="color: #007700">;<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Recreate the "book_ancestors" code as an appropriate plugin.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>Add the necessary logic.</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>A plugin exists that displays the Book Ancestors code.</p> <h3 id="summary-api-changes">API changes</h3> <p>TBD</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>n/a</p>
issue