0

In my template (page.tpl.php file) I have five regions/sections. Header, section#main_prefix, section#main_suffix, and footer. I also have these regions declared in the .info file in my theme. However, my frontpage is only displaying three of those regions; header, main and footer. I created a page--front.tpl.php file and copied/pasted the content from my page.tpl.php file and am seeing no results. Is there somewhere that I need to make a formal link to this, or does drupal automatically know that page--front.tpl.php is the front page? I have not done anything else to specify a homepage and I can't find any other files in the sub or base theme that have the layout of "header, main, footer." It's still just displaying most recent articles.

I need the section#main_prefix to display, because it has a content block that needs to be on the homepage. This is a static block and isn't contextually dependent in any way. I'm aware that if regions don't have content in their blocks that needs to display, that they won't display. I'm also not seeing any problems in my status report.

Background info:

Aurora is my base theme. Theme related modules include:
Magic, HTML5 Tools, Modernizr, Blockify, Borealis Suite, Fences, context, Panels and Ctools. There may be more that are relevant, but I can't think of them at the moment.

I was using panels everywhere previously, but had to abandon it after it had several problems ctools and the patches I applied broke some stuff with html5 tools. I'm now trying to layout all of my pages with code and regular panels, although I'm not sure yet how I'm going to target them, maybe context?

I'm also using the Bear distro package.

Thanks for your time and help! This stack exchange board has been a phenomenal resource in helping me learn drupal so far.,

Cole

ravenswoodGov.info

name =  RavenswoodGov
description =  RavenswoodGov theme based on the Aurora base theme.
core = 7.x
base theme = aurora

; ========================================
; Regions
; ========================================

regions[header]       = 'Header'
regions[main_prefix]  = 'Main Region Prefix'
regions[content]      = 'Main Region'
regions[main_suffix]  = 'Main Region Suffix'
regions[footer]       = 'Footer'

; ========================================
; Stylesheets
; ========================================

stylesheets[all][] = 'stylesheets/style.css'
stylesheets[print][] = 'stylesheets/print.css'

; If installed through Bower
; stylesheets[all][] = 'components/formalize/assets/css/formalize.css'

; ========================================
; Scripts
; ========================================

; If installed through Bower
; scripts[] = 'components/formalize/assets/js/jquery.formalize.min.js'

; ========================================
; Modernizr
; ========================================

modernizr[tests][] = css_boxsizing

; ========================================
; Settings
; ========================================

settings[toggle_node_user_picture] = '1'
settings[toggle_comment_user_picture] = '1'
settings[toggle_comment_user_verification] = '1'
settings[default_logo] = '1'
settings[logo_path] = ''
settings[logo_upload] = ''
settings[default_favicon] = '1'
settings[favicon_path] = ''
settings[favicon_upload] = ''
settings[hide_recomended_modules] = '0'
settings[aurora_enable_chrome_frame] = '1'
settings[aurora_min_ie_support] = '10'
settings[aurora_html_tags] = '1'
settings[aurora_typekit_id] = '0'
settings[aurora_livereload] = '0'
settings[magic_embedded_mqs] = '0'
settings[magic_css_excludes] = ''
settings[magic_footer_js] = '0'
settings[magic_library_head] = '0'
settings[magic_experimental_js] = '0'
settings[magic_js_excludes] = ''
settings[magic_rebuild_registry] = '0'
settings[magic_viewport_indicator] = '0'
settings[magic_modernizr_debug] = '0'
settings[magic_performance__active_tab] = 'edit-dev'
settings[magic_css_excludes_regex] = ''
settings[magic_js_excludes_regex] = ''

templates/system/page.tpl.php

<?php if ($page['header']): ?>
  <header id="header" role="banner">
    <?php print render($page['header']); ?>
  </header>
<?php endif; ?>

<?php if ($page['main_prefix']): ?>
  <section id="main_prefix">
    <?php print render($page['main_prefix']); ?>
  </section>
<?php endif; ?>

<?php if ($page['content']): ?>
  <main id="main" role="main">
    <?php print render($page['content']); ?>
  </main>
<?php endif; ?>


<?php if ($page['main_suffix']): ?>
  <section id="main_suffix">
     <?php print render($page['main_suffix']); ?>
  </section>
<?php endif; ?>


<?php if ($page['footer']): ?>
  <footer id="footer" role="contentinfo">
    <?php print render($page['footer']); ?>
  </footer>
<?php endif; ?>

templates/system/page--front.tpl.php

    <?php if ($page['header']): ?>
  <header id="header" role="banner">
    <?php print render($page['header']); ?>
  </header>
<?php endif; ?>

<?php if ($page['main_prefix']): ?>
  <section id="main_prefix">
    <?php print render($page['main_prefix']); ?>
  </section>
<?php endif; ?>

<?php if ($page['content']): ?>
  <main id="main" role="main">
    <?php print render($page['content']); ?>
  </main>
<?php endif; ?>


<?php if ($page['main_suffix']): ?>
  <section id="main_suffix">
     <?php print render($page['main_suffix']); ?>
  </section>
<?php endif; ?>


<?php if ($page['footer']): ?>
  <footer id="footer" role="contentinfo">
    <?php print render($page['footer']); ?>
  </footer>
<?php endif; ?>
9
  • drupal can automatically understand page--front.tpl.php is the template for front page. From your above description, I didn't get actually what is your requirement. Please be more specific. What is actually you want to do with drupal.
    – Cool
    Nov 25, 2013 at 17:34
  • I just want it to acknowledge page--front.tpl.php. Right now the homepage is only displaying three regions (header, main, and footer) it should be displaying header, section#main_prefix, main, section#main_suffix, and footer. I basically just duplicated my page.tpl.php file and renamed it page--front.tpl.php . I have no idea where it's pulling this old three region template from. Nov 25, 2013 at 18:48
  • 1
    Which version of drupal you are using? In the above description you are mentioned that you are just copied all contents from page.tpl to page--front.tpl.php. So now both files are same. If you want to split main region in to main_prefix and main_suffix in page--front, then just add two more regions in your theme's info file(themename.info) and render those regions in page--front.tpl instead of rendering main region. if you want more detailed answer then share your page.tpl, page--front.tpl and themename.info files here.
    – Cool
    Nov 25, 2013 at 18:58
  • Just updated the post with my templates and info file. I'm currently running core 7.22 . I want both page--front.tpl.php and page.tpl.php to have the same regions so that I can have the same blocks render in them. Nov 25, 2013 at 19:14
  • I mentioned before, but it may be worth rementioning that I've not edited the front page in anyway beyond creating this tpl file. Right now I'm just trying to get it on the same level as my backpages. It still shows the newsfeed and everything filled with all my recently created content. Nov 25, 2013 at 19:17

3 Answers 3

1

Try this code in your template.php

function TEMPLATENAME_preprocess_page(&$variables) {
  if (drupal_is_front_page()) {
    $variables['theme_hook_suggestions'][] = 'page__front');
  }
}
2
  • Thanks, i figured out the issue already, but this is really helpful. It seems like I keep on seeing things about hooks. Is there a video or tutorial I can read about them or is that something general to PHP and not necessarily drupal? Nov 26, 2013 at 17:35
  • There is probably some books you can buy, and have a look on the drupal api online which is really good api.drupal.org/api/drupal/includes!module.inc/group/hooks/7
    – GwenM
    Nov 27, 2013 at 0:18
1

In fact this is just the default behavior : Drupal displays all nodes that receive the "promote to frontpage" setting, in a list of teasers of all published nodes.

There are several solutions to change that.

  1. In a default install, you can edit page.tpl.php as following :

    <?php
      if($is_front){
        $title = ''; // removes 'Welcome to @site-name', or put whatever title you'd like to
        $page['content']['system_main']['default_message'] = array(); // removes 'No front page content has been created yet.'
        //OR
        $page['content'] = array(); // removes completely the 'promote to frontpage' list
      }
    ?>
    
  2. You can create a basic page, set it as your default frontpage in admin/config/system/site-information, and put your some static homepage content in it.

  3. You can use one of the following modules that provide customised home pages dependant on role, or other features:  Front, Empty Page, Empty Front Page... 
  4. You can enable the Front Page view to display your own listing content, display it on a page, give that page a path, and set that path to be the default frontpage.

  5. At minimum, you can uncheck "promote to frontpage" for any content ! But you'll lose the ability to use this flag in a custom way, in custom views i.e ...

By the way any page, be the front one or not, will display the same regions as set in your page.tpl.php except if you play with if($is_front){} in the .tpl or create a page--front.tpl.php. And you'll be able then to specify in admin/structure/block which blocks should go in each region for all pages, for all pages except <front>, or for frontpage only ...

So as your .info and .tpl look correct, check the blocks settings and its content.

0
1

The reason why the regions weren't being displayed is because the blocks in them had every content type checked to display in. In order for something to display on the default drupal homepage, everything has to be unchecked. I don't know why this also didn't prevent things from being displayed in search and other types of system pages, they must be considered "basic pages", but there you have it.

The homepage is a page without a content type, by default. So even if you select it to display in all content types, that means it won't display in non-content types...

In short, if you want a block to show up on the default homepage, don't check anything at all in configure/content types

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