Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4256124
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:18:42+00:00 2026-05-21T05:18:42+00:00

I’m new to Drupal (v6) and PHP, and I’m trying to implement some content

  • 0

I’m new to Drupal (v6) and PHP, and I’m trying to implement some content through a custom module. I’ve followed a tutorial, and figured out how to make Drupal aware of my module and even registered a URL for my custom page. It’s appearing in the navigation as I intended — so far so good.

This is great for my toy example… but less good for the page(s) I actually intend to write. Right now I have this:

function twtevents_menu() {

  $items = array();

  $items['gingerbread'] = array(
    'title' => 'Gingerbread Gallery',
    'page callback' => 'twtevents_gallery_gingerbread',
    'access arguments' => array('access twtevents content'),
    'type' => MENU_NORMAL_ITEM
  );

  return $items;
}

function twtevents_gallery_gingerbread() {
  // content variable that will be returned for display
  $page_content = '';

  $page_content = '<p>'.  t("Some super-cool content") .'</p>';

  return $page_content;
}

But I don’t want to write a large, complex page in the style of $page_content = '<p>'. t("Some super-cool content") .'</p>'; — and on and on.

I want to write the actual page in a style closer to this:

<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status ?> clear-block">
  <?php print $picture ?>

  <?php if ($comment->new): ?>
    <span class="new"><?php print $new ?></span>
  <?php endif; ?>

  <h3><?php print $title ?></h3>

</div>

Where php code is sprinkled into HTML markup, rather than the reverse.

From within my function, I can call include($path) successfully, but (of course) this approach just places the output of my page in the top-left cornet of the broser… I need to send the output of the separate page as the return of my callback function.

Is there a PHP function for this? A Drupal function? Best practices?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:18:42+00:00Added an answer on May 21, 2026 at 5:18 am

    As Kniganapolke says, you want a hook theme implementation to call a template;

    Something like;

    function twtevents_theme(){
        return array(
            'template' => 'twtevents_gallery_gingerbread',
            'arguments' => array()
        ); }
    

    Then place your template code into a file called twtevents_gallery_gingerbread.tpl.php in your module folder.

    Then update your page callback to call the theme function like this;

    function twtevents_gallery_gingerbread(){
        return theme('twtevents_gallery_gingerbread');
    }
    

    Now here is the important bit – once you’ve added the theme hook to your module you must clear your Drupal cache, otherwise it won’t find your new template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.