0

I am creating a custom first page that is blank and built up from scratch. However I want to print certain regions (e.g. the footer) on this page. How can I grab the region information/content and print it in the html in the welcomegeneratepage function.

<?php

//Create the redirect page
function module_name_menu() {
    $items['welcometest'] = array(
        'title' => 'Redirecting',
        'access callback' => TRUE,
        'delivery callback' => 'welcome_blank_page'
    );
    return $items;
}

//Function generate the redirect page
function welcome_blank_page() {
    //Get the redirect URL
    //Generate the HTML for the page
    $html = welcomegeneratepage();
    print $html;
}

//Generates the page html
function welcomegeneratepage() {
    print $footer;
    $html = "<html>
                <head>
                    <link rel=\"stylesheet\" type=\"text/css\" href=\"".drupal_get_path('module', 'module_name')."/css/module_name.css\">
                    <link rel=\"shortcut icon\" href=\"".variable_get('file_'.file_default_scheme().'_path',conf_path().'/files')."/favicon.ico\" type=\"image/vnd.microsoft.icon\" />
                </head>
                <title>
                        Welcome to ".variable_get('site_name')."
                </title>
                <body>
                   <div class=\"welcomecontent\">
                       <div class=\"welcomemessage\">
                           <h2>Welcome</h2>
                       </div>
                   </div>
                </body>
             </html>";
    return $html;
}

1 Answer 1

1

I haven't had any need for a blank page before, but couldn't you just create a new .tpl.php for the front?

Under site configuration, set a node as your front page, then create a copy of page.tpl.php and name it page--node--1.tpl.php (or whatever node ID you have) .

Delete all the divs and containers to make the page blank, and then render regions in php like normal.

print render($page['your_region']);

2
  • This is a bit new to me. Let's say I want to make the front page called www.example.com/frontpage. Do I first need to create a basic page and then make a page--fontpage.tpl.php? I am using clean urls.
    – John
    Commented Apr 27, 2014 at 18:19
  • You would create the page "frontpage" then check its alias, which will be something like node/1 then copy the existing page.tpl.php and rename the copy page--node--1.tpl.php then flush all caches, and edit the copied template as much as you like.
    – Collins
    Commented Apr 27, 2014 at 18:31

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.