1

I made a module, that outputs the data when the user opens a page /courses

function courses_menu()
{
  $items['courses'] = array(
    'title'            => t('Courses'),
    'page callback'    => 'courses_output',
    'access arguments' => array('access content'),
  );
}

function courses_output()
{
  return "some HTML";
}

How can I add this data to the main page below the node contents?

2 Answers 2

1

I would either implement a block or if you are using panels create a content pane.

3
  • IMHO, implementing a block would be overkill. If you really want to go for a pure Drupal way, go for a yourtheme_preprocess function and set a variable to your function's return value, then print it in your template as stated below.
    – Countzero
    Commented Feb 23, 2012 at 16:41
  • You lose a lot of Drupal's flexibility by not implementing it as a reuseable object(block/pane). Say a customer figures out that he want it on some other page afterwards or don't want it on this specific node or but on all of this node type etc. or only want it shown for certain users. Then you will end up with a lot of business logic in the theme instead of keeping it either in configuration or a module.
    – lslinnet
    Commented Feb 29, 2012 at 15:10
  • You're right. But it all depends on the use case. Here, the logic seems to be to output some static HTML, so it seems unlikely this will have to be displayed elsewhere than in the original place. I tried to answer as close as possible to the OP perceived level of mastery, but it's only guessing, of course. Your answer is more universal, but maybe less adapted to the OP level. It's on his behalf to pick up what fits his needs the best.
    – Countzero
    Commented Feb 29, 2012 at 17:30
-1

You could just add a call to your function in your page-front.tpl.php :

print courses_output();

It's not the standard way : you should use a preprocess function etc. but it's straightforward.

1
  • 1
    I would recommand you don't do it this way.
    – lslinnet
    Commented Feb 23, 2012 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.