0

I am trying to create a special template page for a group of pages by following Creating a page.tpl.php template for a group of pages (Drupal 7)

I created a page--sales.tpl.php file

<div id="page-wrapper">
  <div id="page">

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

    <div id="main-wrapper">
      <div id="main" class="clearfix">
        <?php if (isset($page['content'])): ?>
          <?php print render($page['content']); ?>
        <?php endif; ?>
      </div>
    </div>

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

And my content template looks like

<table>
  <tbody>
    <tr>
      <th><h3> <?php print t('Sale Order ID') ?></h3></th>
      <th><h3> <?php print t('Date | Time') ?> </h3></th>
      <th><h3> <?php print t('Download File') ?> </h3></th>
    </tr>
    <?php foreach ($sale_orders as $sale_order): ?>
      <tr>
        <td> <?php print $sale_order['sale_order_id'] ?> </td>
        <td> <?php print $sale_order['sale_order_date'] ?> </td>
        <td> <a href="<?php print $GLOBALS['base_url'] . '/sales/download/' . $sale_order['account_download_id']; ?>">
            <?php print $sale_order['file_name'] ?> </a>
        </td>
      </tr>
    <?php endforeach; ?>
</table>

I assumed that the sidebar won't show, because in page--sales.tpl.php does not render $page['sidebar_first']. But I found that as soon as I render $page['content'], I will get the side bar contents as well.

I think my problem is not understanding how $page['content'] is generated. Do other parts such as breadcrumb and sidebar get "embedded" into $page['content'] before the the page--sales.tpl.php file get processed?

Thanks for your help.

4
  • 1
    It sounds like your sidebars are in the content region, not sidebar_first...does that sound right?
    – Clive
    Commented Apr 22, 2014 at 16:47
  • You could be right. But I am not sure how the region is generated. Can you point a link that explains such concept?
    – Wei Ma
    Commented Apr 22, 2014 at 16:54
  • This explains it quite well...
    – Clive
    Commented Apr 22, 2014 at 16:56
  • Thanks. I check my site admin setting. And the side bar is actually in sidebar_first region.
    – Wei Ma
    Commented Apr 22, 2014 at 17:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.