0

I'm using page callback function to display a page. How would I change this to use an omega template? I've tried adding a vis.tpl.php to the omega templates function but to no avail. I don't understand how to declare a omega template for use with a particular page.

<?php

function vis_menu() {

  $items['images'] = array(
    'title' => 'Images',
    'page callback' => 'image_page',
    'access callback' => TRUE,
  );
  return $items;
}

function image_page() {
  return 'hello';
}

Any help would be much appreciated.

0

I solved this using this question as a basis to work from https://stackoverflow.com/questions/4100485/register-your-theme-functions-in-drupal.

The template (.tpl.php file) goes in the omega template directory. You then use a hook_theme function to define the theme with the template key in the array pointing to the name of your template file.

The theme is then called with theme(your-theme-name)

Here's my working example for my module called vis:

function vis_menu() {

  $items['images'] = array(
    'title' => 'Images',
    'page callback' => 'image_page',
    'access callback' => TRUE,
  );
  return $items;
}

function image_page() {
  return theme('images');
}

function vis_theme() {
  return array(
    'images' => array(
      'variables' => array(),
      'template' => 'vis',
    ),
  );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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