0

I have a couple of node types, policy, quote, customer etc and each of those has a set of actions called that are printed in a menu of links which are coded into the template file. I want to put this menu into a block so that I can reposition it, so the block needs to be dynamic.

I was going to just create a block in a module, and in the $block['content'] just foreach out an array of actions...but I can't find out how to firstly make those variables available to the block and secondly where to do so.

I looked at preprocess functions but I could only make out that they are for passing variables to the template rather than to a block. Does anyone have any suggestions here, otherwise it seems that blocks are just completely isolated?

The only other way I thought to do it would be to get the node Id from the arg() and load it, then a switch statement depending on the node type to add the actions - but that seems like a very messy and roundabout way to do it, especially when adding node types int eh future.

apaderno
  • 28,547
  • 16
  • 75
  • 90
Michael Mallett
  • 734
  • 1
  • 12
  • 28

1 Answers1

0

You probably want to use panels to provide these "panes".

You can render your nodes in "full content mode" in a pane on a panel and they will automatically get your links from the tpl and you gain alot more power over their selective display, context and relationship to the other content on the page.

Drupal 8 is going the ctools panels route so its worth your time to spend a minute to learn. Please feel free to ask any questions you have about

Michael Favia
  • 219
  • 3
  • 6