While I realize this does not address all of the permissions/view feature requests in the open issues list the attached patch at least mirrors the functionality in the core book block to only show the block on book pages.

CommentFileSizeAuthor
show_on_book_pages_only.patch7.27 KBdworth

Comments

hanskuiters’s picture

Could it be you switched the 'old' and 'new' file while creating this patch? This patch doesn't make sense the way it is now...

hanskuiters’s picture

I got it working. Thanks for the patch, although still old and new switched on creating the patch.

_vid’s picture

I'm looking forward to checking out the patch.
I didn't see this issue and I addressed this problem using jquery this week.

This code checks the menu for any active li's and hides the block if none are found (currently hard coded to look in #sidebar-left).

Drupal.behaviors.siteMapHighlight=function(context){
	//run only if there is a context var
	if(typeof context !== 'undefined'){
		/*
		Check the type of the context var and type. Process if context = [object HTMLDocument]
		Note: when context == [object HTMLDocument] then this is page load. You may want some script to run only on page load. Some not and some all the time.
		*/
		if(typeof context == 'object' && context.toString().indexOf('HTMLDocument')!=-1){
			//Page Load

			//advancedbookblocks add-on script to hide empty menus
			if($('#sidebar-left .block-advancedbookblocks').length >= 1){
					itemsDisplayed=false;
			
					$('#sidebar-left .block-advancedbookblocks > .content > ul.menu li.active').each(
					function(){
							//alert($(this).css('display'));
							if ($(this).css('display')!=="none") {
									//alert('found one');
									itemsDisplayed = true;
							};//end if
					}); //end each function()
					if(!itemsDisplayed){
							$('#sidebar-left .block-advancedbookblocks').hide();
					}//end if
			}//end if($('#sidebar-left .block-advancedbookblocks').length >= 1){
		}//end if typeof context... page load
	}//end if typeof context !== undefined
}//end Drupal.behaviors.siteMapHighLight

This relies on some styles I have that show only the current book's menu and hides the others.

/*Nav menu*/
#sidebar-left .block-advancedbookblocks > .content > ul.menu > li {display:none;}
#sidebar-left .block-advancedbookblocks > .content > ul.menu > li.open,
#sidebar-left .block-advancedbookblocks > .content > ul.menu > li.active {display:block;}

CSS also posted on this issue: http://drupal.org/node/384546#comment-5200304

Note: edited 4/2/2012 for grammar.

ginorodrigues’s picture

That´s a valuable patch for this module, but do I still have to place any block on that region?