Problem/Motivation
There is no way to get the Book menu tree plugin. Further more some text are swapped.
Proposed resolution
Fix texts to help people place the correct widget.
Add plugin : plugins/content_types/node_context/node_book_menu.inc
Remaining tasks
User interface changes
API changes
Original report by @bomarmonk
I checked out the usual issues related to the "add content" blocks, etc. not showing up, but are there other ways to trouble shoot this? I tried uninstalling all of the panels related modules, reinstalling, and reenabling them. The book navigation block, for instance, can't be added to a panel, because it's not available in the "add content" pop-up. However, its checkbox is checked under the setting for adding it to panels and mini-panels. Any help would be appreciated.
Comment | File | Size | Author |
---|---|---|---|
#79 | interdiff.txt | 1.47 KB | rivimey |
#49 | adding_book_navigation-640226-49.patch | 6.67 KB | clemens.tolboom |
#71 | adding_book_navigation-640226-67.patch | 6.56 KB | rivimey |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedA couple of blocks are specifically hidden:
It's possible that I've removed these without providing proper replacements but I think both of them can be properly done if you have context.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedComment #4
manogolf CreditAttribution: manogolf commentedA favor please.
Until I understand how to recreate the book navigation block with context can you let me know where I can uncomment/delete the php that hides the book navigation block. I can't seem to find it.
Thanks
Comment #5
manogolf CreditAttribution: manogolf commentedComment #6
timwoodmanogolf,
Please share what you did to get the book navigation working.
Thanks,
-Tim
Comment #7
manogolf CreditAttribution: manogolf commentedTim,
I never did find the code that blocked the book navigation block, but then I'm not the shiniest penny in the role either. I solved by creating a view with the field of node titles, and filtering with node type = book page, and book depth = 1. Can't be sure if this works for everyone though.
I had four existing books, and wanted to show them on my panels built homepage. I provided the title for the views built book navigation block in views (It really is just a set of links to the books). Then displayed the view in a mini-panel aside three other views built content displays.
You can see the result on my homepage at http://manogolf.com in the lower left titled "Fantasy Golf League Results'.
I'm not the best source for problem solving as most of my work is a struggle at best. Eventually it somehow gets pulled together though.
Hopefully this helped?
Jerry
Comment #8
timwoodJerry,
Thanks for the reply. I was hoping for a block that would show book navigation just for the book you were currently viewing. Looks like the default book navigation block (which I just enabled via the blocks system to test) shows all books navigation, even if you are viewing a page within a specific book. So I doubt exposing the book navigation block in a panel would get me what I want. I'll look into creating a view with an argument for the parent book, so I can limit the navigation to the current page's book.
Still, the Panels module shouldn't arbitrarily disable/hide certain blocks.
-Tim
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedSorry, the code that removes those blocks is in the block.inc content type.
Comment #10
Vote_Sizing_Steve CreditAttribution: Vote_Sizing_Steve commentedThis 'block.inc' file is located at "ctools/plugins/content_types/block/block.inc".
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedNote that there IS a replacement book navigation that uses context. It will be under the 'Node' category (which only appears if you have a node context available) and is called Book navigation.
Comment #13
wj-2 CreditAttribution: wj-2 commentedHi Merlin,
It is not a replacement in the sense that both produce different outputs. In my case I want to have a navigation-menu-like overview of the Book that shows the current selection in the context of the book's outline. Anyway that is exactly what the Book navigation block provides. So, my question is why the Book navigation block is actually hidden from the Add Context selection? Is it because it might be confusing because of the name?
Thanks,
Willem
Comment #14
Melissamcewen CreditAttribution: Melissamcewen commentedI put it back on my own installation. Currently with Views there I couldn't find a way to get something like that with the hierarchy in place and showing the current position in the book.
Comment #15
rumblewand CreditAttribution: rumblewand commentedHey there! At first glance this appears to be working. Create a custom block - add this code to the body and make sure you have format set to php.
I'm doing this on a Node panel so it uses the %node:nide context to pull that books' info. I just wonder how to exclude the top page from the list. I'll play with it.
I'm using drupal 7 panels but I think you can modify the original code found at http://drupal.org/node/44648 to suit your needs.
Comment #16
rumblewand CreditAttribution: rumblewand commentedOk that only worked on the first page of the book. I tried to implement
by adding a book parent relationship but can't get it to work on child pages? Anyone else able to chime in for the D6 or D7 version?
Comment #17
rumblewand CreditAttribution: rumblewand commentedupdated title to better reflect theme of discussion
Comment #18
Renee S CreditAttribution: Renee S commentedThere really is no decent replacement for this block, unfortunately, it's too tied in with Book. Hiding it is... painful. Is there really a good reason to have it be hidden and not let the user decide if they want to use the (less configurable by default) node context-version, or the default Book Navigation block, on their own?
Comment #19
Renee S CreditAttribution: Renee S commenteddp
Comment #20
rumblewand CreditAttribution: rumblewand commentedYay - sort of. Just doesn't show the top level title link of the tree.
Make sure you have added a book parent relationship.
Then add a Book Children content pane from the available Node selections. Have it set to show for Book Parent.
I personally do not need the top book title at the top of my list since my users are only able to see one book at a time but if you do - try my original idea from #15,#16 and break it into two panes.
One pane with
and one with
Comment #21
rumblewand CreditAttribution: rumblewand commentedI'm still not happy with the implementation I came up with. Works so so for one level books. Also, found this - http://drupal.org/project/bookblock which I really like except that you have to check off each of the books you want to make a block for. Not so hot if your users are creating books.
Comment #22
rumblewand CreditAttribution: rumblewand commentedAlright - I gave up. I commented out lines 315 - 319 in the block.inc file for ctools (drupal 7 - same code as merlin's above). Shows up fine now in the content list to add to a pane. Works as expected and I'm pleased. As my php coding progresses I'm sure I'll take a crack at bringing it in as 'context aware' (since I'm assuming that is why it was disabled) OR I'll try to make some type of options addon for cpanels that allows you to check on/off to add drupal missing items.
Good luck to you all! Feel free to close this out since I reopened it unless anyone more experienced than me can come up with a better solution.
Comment #23
Renee S CreditAttribution: Renee S commentedI don't want it closed! :) I'm convinced that, community-wise, disabling another module's blocks is not good practice, regardless of the altruistic reasons for the change. Especially since the replacement is not nearly as simple, and leaving it in place harms nothing.
Comment #24
jackbravo CreditAttribution: jackbravo commentedI agree with Reinette. That block should not be disabled. The Book Navigation proposed as a replacement that is under the Node category show a different thing and is no good. It shows a Next page, top page, Previous page navigation. Instead of a hierarchical list of all the nodes within the book I'm currently seeing.
Comment #25
djh007 CreditAttribution: djh007 commentedsubscribing...
Comment #26
rumblewand CreditAttribution: rumblewand commentedit sounds to me like this has turned into a feature request? Updating...
Comment #27
spineless CreditAttribution: spineless commentedThis sounds like a bug to me.....
I want to create a panel that will display the parent page of a book when the user is on a child page. The tools are available in the panels admin screens but I do not think it is working.
I am looking at the following settings page.
Administrator --> structure--> mini panels --> settings ( of the selected mini-panel) --> content -->add content --> node tokens - book
on this page there are some variables to select the
1. node or the book parent
2. override title
3. Sanitize
This feature does not display anything no matter what combination of settings i am selecting. Is there something wrong here? i am assuming that when I am viewing a child page i would expect to see the book title displayed for that child in the panel.
Any idea why this does not work?
How can I display the book title of any child page?
Thanks,
Spineless
Comment #28
rumblewand CreditAttribution: rumblewand commented@spineless try looking in the "replacement patterns" section. It will end up being something like "%book_parent:title" that you will use. I haven't tried node tokens in mini panels but try custom output using the replacement pattern and see if that helps. Otherwise it might be a different issue?
Comment #29
spineless CreditAttribution: spineless commentedYes I agree. I should be able to use a substitution. I tried that several different ways to see if it would take. I am not sure what would prevent this from working. I have seen this error in other modules as well. Maybe there is a bug in the core or I am not using the %book_parent:title string the right way.
I even tried other string to point at different nodes such as
%node:book
%book_parent:nid
%node:author
I am using the override title cell in the content screen for min-panel.
i think there might be an issue with the Node (token) option. I tried to select author as a node token and this did not work either.
Any ideas how I can troubleshoot this?
Thanks,
spineless
Comment #30
rumblewand CreditAttribution: rumblewand commented@spineless, sorry, I don't use mini panels.. open a new issue though and I'm sure someone will chime in.
Comment #31
rootworkI'm still confused as to why the book navigation is being intentionally disabled. After spending hours trying to create the "rich" block made possible by contexts, I stumbled upon this thread, commented out the code in #9 , and immediately had exactly what I needed.
I'm the first to say that the entire book interface sucks. But hiding a built-in function when panels/ctools doesn't provide anything similar out of the box seems misguided. Unless the default book navigation somehow interferes with the context-enabled book navigation (and I don't think it does, as I had both operating at the same time when I first commented out the code), I don't really see why this should be getting disabled.
I guess for now I'll create a custom module that specifically overrides the panels/ctools function. But this seems really silly. Just let the default book navigation appear, and allow power users to create their own custom versions using contexts.
Comment #32
Letharion CreditAttribution: Letharion commented@merlin
I'm not sure I understand exactly why you have hidden this block?
I'm not really familiar with the Book module, but we don't intentionally hide any other of Drupal's subsystems, do we? I'm not really a fan of blocks, and sometimes I wish Panels could be a blocker for "Block", but not everyone feels that way, and it seems to me like we should unhide this.
Unless we provide a better implementation ofc :)
Comment #33
jwilson3+1
I'll join the vote, along with jackbravo, Letharion, rootwork, spineless, and Reinette.
This is currently prohibiting me from recreating a simple book node layout using Panels. My ideal layout would be similar to documentation pages on d.o, with a sidebar navigation of the entire book structure in addition to the regular (node context) Book navigation underneath the body.
Comment #34
jwilson3In comment #1 of #1405682: Node/Book Navigation shows current level only Earl describes a way to make the current Book navigation pane provided by Panels show the level 1 book links, even if you are inside a book, a couple levels deep. However, if you are on a book page below L1, this workaround does not *expand* the navigation links with active-trails down into the current page, so it does not work as a general solution for a replacement for the missing book navigation block.
Comment #35
jwilson3Part of the confusion on the part of CTools may come from a befuddled core block / template names in the book module. The term 'navigation' in the book module is thrown around loosely to mean either:
book-navigation.tpl.php
is used to theme a book page's contextual navigation (ie, the horizontal *pager* navigation shown in the content of a book page node).book-navigation.tpl.php
, but ratherbook-all-books-block.tpl.php
.The current "Book navigation" pane provided by CTools offers support for only option 1, while I think what most people here are asking about is support for option 2.
The first thing I tried was to simply un-disable the default navigation block in ctools/plugins/content_types/block/block.inc
This works but it's not ideal in two ways:
- it effectively creates *two* panes with the same name "Book navigation". I solved this by tweaking the title of the pane in node_book_nav.inc to the more apt 'Book pager', and the core block to 'Book menu'.
- the core block menu doesn't take advantage of panels contexts, however, this may not be necessary -- it satisfied my needs.
The second thing I looked at was to add logic into the Book navigation CTools implementation that would add option 2 functionality, however, the problem then becomes that we'd have to completely duplicate the code from book module's block_block_view() just in order to get proper CTools contexts to work. This is because core book module depends on core's concept of "context", namely, the menu system, to obtain the node object to build the navigation. It's a good chunk of 35 lines of very specific book module code that I'm not sure belongs duplicated in CTools module.
So given these circumstances, I think the first solution is better.
One additional change that I'd like to do is adjust the icons, so they match their underlying functionality. This patch does that as well.
Comment #36
merlinofchaos CreditAttribution: merlinofchaos commentedI think I would rather just duplicate the code and provide a proper book navigation pager that utilizes context. The whole point of this system is to get around core's lack of context.
Thanks for clarifying that I was actually providing the wrong thing; I don't think I understood that, and there's a lot of system so lots of stuff falls in the cracks.
Comment #37
bulldozer2003Comment #38
merlinofchaos CreditAttribution: merlinofchaos commentedAs I said, I didn't realize at the time I was providing the wrong thing. We need to provide the right thing.
Comment #39
jwilson3As Merlin said in #36, the proper solution would be for CTools to *provide* the context-aware book navigation.
So where are we?:
Anyone who has the time and need, please take my patch in #35 and run with it... to create a fully context-aware replica of the book navigation.
Comment #40
clemens.tolboomI've applied the patch to the ctools project. It works as expected.
Viewing a non book page still shows the book outline. Not sure why. Panels cache?
and it's structure
So this needs some work but it looks as expected regarding the book hierarchy.
I hope this patch can get in asap as missing the book structure blok is a pitb
Comment #41
clemens.tolboom#40 is a user err ... one must configure the block settings 'Only show on book pages'
Attached patch is hopefully what @merlinofchaos said in #36.
I did not manage use the block settings 'all pages' , 'book pages' choice.
Also the $block->subject (which should contain a link to top level book page when 'book pages') is not displayed.
Comment #42
clemens.tolboomI've kept status to needs review as I need help. See below for the help parts.
Where should the settings come from?
Commented to keep code similar from function book_block_view
Do we want to keep is similar or delete not needed lines?
Ditto
Ditto
This is in the original version link to top level item.
Is this wrong? Setting is not kept :-/
Comment #43
clemens.tolboomTo test against core behaviour add these lines and configure the block though block admin page. See #35
Still needs review | help
Comment #44
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks! I was looking for this very thing and your patch worked for me.
Comment #45
clemens.tolboom#41: ctools-book-navigation-menu-640226-41.patch queued for re-testing.
Comment #46
tygbiten CreditAttribution: tygbiten commentedIf it helps at all:
I got the block title to render correctly by setting $block->title = $block->subject and not using the override title option.
Comment #47
jelo CreditAttribution: jelo commentedIf someone is still looking for a solution regarding ctools/panels and book navigation, try menu block module (https://drupal.org/project/menu_block). Although panels in the latest version allowed me to place the actual book navigation into my node panel, it did not behave as I expected. I wanted a tree structure that showed the hierarchical depths of the book with the child pages floating immediately below the parent when the parent is the active item. It worked very nicely with menu block, I just had to do one workaround to get the child pages to show up on the top level book parent. I did that by using the "book children" block which is listed under "Node" in panels and using visibility to only show it on the top level book page. No contexts need to be set...
Comment #48
clemens.tolboomThis issue was a support request changed into bug report but we never changed the title.
I've reapplied the patch without any trouble.
Comment #49
clemens.tolboomPatch from #48 missed lines to show the block at all.
Comment #50
clemens.tolboom[edit]Removed noise[/edit]
Comment #51
AndreyMukha CreditAttribution: AndreyMukha commentedWhen book navigation block place in panel and i select parent book - Notice: Undefined index: form_build_id in ajax_get_form() (line 321 of /home/u5673/domains/my_site/includes/ajax.inc).
http://joxi.ru/1cXOU_3JTJD-R4Uctfg
Comment #52
wimberb CreditAttribution: wimberb commentedAny chance of getting this finalized and committed? I'd really like to have this functionality without having to patch every time there is an update.
Comment #54
richH CreditAttribution: richH commentedHi,
really really need this......
Would be cool if could be updated.
Thanks
RIch
Comment #55
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedPatch still applies to 7.x-1.7, works as expected.
Comment #56
DamienMcKennaThere are several todo items listed in the patch, are they important enough that they could prevent the patch from being committed?
@AndreyMukha: Could you please clarify - did you apply the patch before the error started showing? Which pane did you add to the page - "Book navigation menu" or "Book navigation pager"?
Comment #57
skimi CreditAttribution: skimi commentedWorking as expected for me too. Could not reproduce #51.
I'm going to prod with this patch. Hope it'll get committed.
Comment #58
rajmataj CreditAttribution: rajmataj commentedPatch #49 does not work with 7.x-1.9. Will keep a keen eye on this ticket to see if/when it gets into a stable release. Thanks.
Comment #59
rootworkSince this was still assigned to merlin from years ago (and that assignment was I think mostly to try to get him to review it) I'm unassigning it in the hopes this can be pushed forward.
Comment #60
jenlamptonI think my issue over here might be a duplicate of this one:
https://www.drupal.org/node/920010
thoughts?
Comment #61
brooke_heaton CreditAttribution: brooke_heaton commentedThis patch is absolutely necessary. Thanks.
Comment #62
clemens.tolboom@jenlampton I closed #920010: 'book navigation' block missing from Panels / Page manager UI as that looks similar.
@brooke_heaton + other please test the patch as @helmo said it still applies. Or you could hire someone to do so.
Comment #63
clemens.tolboomComment #64
jonraedeke CreditAttribution: jonraedeke commented#49 Patch works well for me. I'm using 7.x-1.9
Comment #65
hawkeye.twolfWorks great. Would recommend using the book's title as the default, like the regular block used to do. Also, for me, I get double Book Navigation panes showing. Is it possible to disable the original version?
Comment #66
jenlamptonThis patch solves my problem from https://www.drupal.org/node/920010#comment-7305802 too. Thanks all!
Comment #67
rivimeyPatch applies cleanly to current 7.x-1.x in git.
A visual code review prompted the following changes but I don't want to derail the patch overall -- it's been long enough already! Attached is an interdiff that includes both of the changes:
== Spelling & Remove unnecessary code.
diff --git a/plugins/content_types/node_context/node_book_menu.inc b/plugins/content_types/node_context/node_book_menu.inc
index ddccadc..8fe2936 100644
--- a/plugins/content_types/node_context/node_book_menu.inc
+++ b/plugins/content_types/node_context/node_book_menu.inc
@@ -31,12 +31,8 @@ function ctools_node_book_menu_content_type_render($subtype, $conf, $panel_args,
// TODO: the value is not available somehow?!?
$book_block_mode = isset($conf['book_block_mode']) ? $conf['book_block_mode'] : 'book pages';
- // Code belong is taken from function book_block_view($delta = '') {
- // $block = array();
- $current_bid = 0;
- // if ($node = menu_get_object()) {
- $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
- // }
+ // Code below is taken from function book_block_view().
+ $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
if ($book_block_mode == 'all pages') {
$block->subject = t('Book navigation');
if ($book_block_mode == 'all pages') {
$block->subject = t('Book navigation');
== Promote weak "==" to strong "==="
diff --git a/plugins/content_types/node_context/node_book_menu.inc b/plugins/content_types/node_context/node_book_menu.inc
index 8fe2936..84497c8 100644
--- a/plugins/content_types/node_context/node_book_menu.inc
+++ b/plugins/content_types/node_context/node_book_menu.inc
@@ -34,12 +34,12 @@ function ctools_node_book_menu_content_type_render($subtype, $conf, $panel_args,
// Code below is taken from function book_block_view().
$current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
- if ($book_block_mode == 'all pages') {
+ if ($book_block_mode === 'all pages') {
$block->subject = t('Book navigation');
$book_menus = array();
$pseudo_tree = array(0 => array('below' => FALSE));
foreach (book_get_books() as $book_id => $book) {
- if ($book['bid'] == $current_bid) {
+ if ($book['bid'] === $current_bid) {
// If the current page is a node associated with a book, the menu
// needs to be retrieved.
$book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
Comment #68
rivimeyIn addition, the new files/functions should really be covered by test code. Could Clemens help do something (given he wrote the current patch)? On the other hand, none of the other plugins have tests that I can see, so perhaps this can be overlooked?
Comment #69
rivimeyComment #70
clemens.tolboom@rivimey I don't get #67.
adding_book_navigation-640226-67.diff looks like a patch file to me ... so what is changed between #48 and #67 (add an inner diff)
Please install Dreditor (on Chrome) for code comments and patch review. Works way better ;-)
[edit]See https://www.drupal.org/patch for patch and innerdiff[/edit]
Comment #71
rivimeyAdding actual patch file that wraps up patch from #49 with my interdiff in #67.
[apologies: adding_book_navigation-640226-67.diff file should have been named adding_book_navigation-640226-67.txt]
Comment #72
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedhiding all the older patches ... somehow only the older ones are showing up at the summary.
Comment #73
rivimeyComment #74
clemens.tolboom@rivimey what are the changes between #49 and #71? Is it possible to provide an inter diff? See https://www.drupal.org/documentation/git/interdiff
Comment #75
clemens.tolboomDarn ... we have #49 which got RTBC #66 and now there is #71 which needs tested. So set to 'Needs review'
Comment #76
rivimey@clemens the changes included in the patch in #71 are exactly the ones listed in the comment of #67 - nothing else.
I spoke with Jakob at DrupalCon and he was ok with including #71 without reset to Needs Review, given the very limited nature of the change. I don't mind, but I would definitely prefer skipping my change entirely to not including the patch in the next release.
So, reviewers to the fore for #71, or we go with #66
Comment #77
izmeez CreditAttribution: izmeez commentedIf i understand the patch in comment #71 is a modification of the patch in #49 based on a code review and that tests are not needed to get this committed.
Unfortunately, when the patch was posted in comment #71 it was not accompanied by an interdiff file to allow a quick review of the proposed changes found on code review to the patch that is already RTBC.
Referring to comment #67 to unravel this is not as helpful and does not permit a quick review.
Comment #78
izmeez CreditAttribution: izmeez commentedModifying title for better clarity.
Comment #79
rivimeyOk, I have wrapped the changes from #67 into an interdiff file. No new changes made c.f. what is in #67
Comment #80
DamienMcKennaThis wasn't added to 1.11.
Comment #81
izmeez CreditAttribution: izmeez commentedComment #82
rivimey@DamienMcKenna, @izmeez, @clemens.tolboom: My apologies for the patch confusion, but can we now return to RTBC? I don't think it is appropriate for me to change as my patch is the latest, but I'm not 'invested' in my patch and would prefer #49 being applied to #67 not being applied :-)
Comment #83
DamienMcKennaComment #84
webt CreditAttribution: webt commentedUse https://www.drupal.org/project/panels_php with code
Comment #85
rivimey@webt, I am not sure what your comment is saying; can you please elaborate?
Comment #86
DamienMcKennaComment #84 provides an alternative means to add the book block as a pane, but it is ill advised because as site builders we shouldn't be making it easier for people to add PHP code through the admin UI.
Comment #87
japerryI think 67 is fine. Fixed and Committed #71 (patch 67).