0

I have two content types Book and chapter . Every chapter is linked to a single book content type by using reference module. i have two blocks which list books in one block and the second one is used to show the chapters in that book. Here are my questions 1) How to display the related chapter in the second block? 2) How to re-render the second block when clicking the first block value ? That is when clicking the book the chapters block should be renrendered and display the referenced chapters of that book .

Books and chapter are just for example I use 2 different custom content type. please dont suggest me books module. If any module available for this scenario please let me know

Monish
  • 121
  • 1
  • 4

1 Answers1

0

What you could do, is to give the chapter buttons/links a query parameter. So when a user clicks on a book, it reloads the page with the current URL + ?book=happybook.

Then implement a hook_block_view() in a module somewhere. https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_view/7

or hook_block_view_alter() https://api.drupal.org/api/drupal/modules!block!block.api.php/function/hook_block_view_alter/7

What you can then do is, read the query parameter in the hook_block_view function and depending on that, show or hide certain content, alter it, etc.

Does that help? Or do I need to describe it a bit more.

Gonzalioz
  • 612
  • 2
  • 6
  • 17