0
votes

I have been asked to build a custom landing page / section of an existing Drupal 7 site via a custom module but the section needs to have a design that is completely different than that of the parent site. It's just a full size background image, no navigation, no footer, no header, and a new form.

Can you remove all the base site theme from a 'page' via custom module so you can create a custom design?

1

1 Answers

1
votes

Short answer: Yes you can! It would require a lot of work, but you can.

Long answer: If the requirement about the solution coming from a custom module is strict, then skip to the last part of this answer. Otherwise you're welcome to fully read it.

What I would do

If the requirement about custom module is not strict, you can just create a page and add a custom template for it. Take a look at Template (theme hook) suggestions

i.e. Create a page called My custom page and let's say the Node id is 23, so you can create a file called page--node--23.tpl.php inside the current theme.

In that page you can modify all the html you need (even the header, footer, etc.)

Custom module

If the solution above does not work for you, you'll have to:

  1. Create a custom module
  2. Create a custom theme

In the custom module you can add a new path like this:

<?php
function mymodule_menu() {
  $items['my-page-path'] = array(
    'page callback' => 'mymodule_render_page',
  );
  return $items;
}
function mymodule_render_page() {

  // Render your content
}

Later use the hook_custom_theme, in the module, to load your custom theme when certain criteria is met.

Something like:

<?php
function mymodule_custom_theme() {
  if ($criteria_is_true) {
    // Use the machine name of your custom theme
    return 'my_custom_theme';
  }
}