Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1006921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:32:19+00:00 2026-05-16T08:32:19+00:00

I’m trying to create a teaser node template to display all Blog teasers. For

  • 0

I’m trying to create a teaser node template to display all Blog teasers.
For the page tpl I have page-blogs.tpl.php
For the Blog node tpl I have node-blog.tpl.php (This one is looping to display all the blog teasers)
Now how do I create a node template to surround the node teasers?
My URL for the page with all the blog teasers is: /blogs/eric
My URL for the page with an example blog entry is: /blogs/eric/test-blog-1
I need a node template that I can use for all the Blog pages.
I tried using node-blogs-teaser.tpl.php for the individual teaser nodes and node-blog.tpl.php for the outer blog node template, but that didn’t work.

Here is what I have in my node-blog.tpl.php file:

<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<div class="item">
<ul>
<?php print $picture ?>

<?php if ($page == 0): ?>
<?php endif; ?>

  <div class="content clear-block">

    <li class="title"><h4><?php print $title ?></h4></li>
    <li class="photo"><a href="#"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></a></li>
    <li class="desc"><?php print $node->content['body']['#value']; ?></li>
    <li class="link">
    <?php if ($teaser): ?>
    <a href="<?php print $node_url ?>" class="block-link">Read more</a> | <a href="<?php print $node_url ?>" class="block-link">Audio/Video</a> | 
    <?php endif; ?>
    <?php print $submitted; ?>
    </li>
    <div class="clear"></div>     

  </div>

  <div class="clear-block">
    <div class="meta">
    <?php if ($taxonomy): ?>
      <div class="terms"><?php print $terms ?></div>
    <?php endif;?>
    </div>

  </div>
</ul>
</div>
</div>

thanks

UPDATE: I added a page preprocessor function in template.php :

/**
 * Override or insert PHPTemplate variables into the templates.
 * These are the main outer templates such as page.tpl.php 
 */
function phptemplate_preprocess_page(&$vars) {

    // add template hints using path alias
    $alias = drupal_get_path_alias($_GET['q']);
    if ($alias != $_GET['q']) {
        $template_filename = 'page';
        foreach (explode('/', $alias) as $path_part) {
            $template_filename = $template_filename . '-' . $path_part;
            $vars['template_files'][] = $template_filename;
        }
    }
    //---- 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:32:20+00:00Added an answer on May 16, 2026 at 8:32 am

    Assuming your content type is called “blog”, then node-blog.tpl.php will be used whenever a blog post needs to be displayed. The $teaser variable will be set to TRUE in node-blog.tpl.php if Drupal is wanting the teaser display, and the $page variable will be set to TRUE if the node is being shown in full page view (they will both be FALSE if the full node is being shown in a list of nodes). So you need to set up your node-blog.tpl.php to check for what type of display is being requested and return the HTML appropriate to the given type. The general setup of your node-blog.tpl.php should be along these lines:

    if($teaser){
      //return teaser html
    }
    else{
      //return full node HTML
    }
    

    It’s a little unclear to me from your question, but it sounds like you might have some sort of looping code in node-blog.tpl.php to iterate over the nodes on your site. You do NOT want to do this. Drupal does not work like WordPress.

    You don’t mention how your list of teasers is being generated at /blogs/eric but I’d recommend using the Views module. If you use Views to generate the list of teasers then you’ll be able to easily theme the list using Views’ theming.

    Edited since you added your example code
    To stick arbitrary HTML at the top of ONLY the full node display of a blog page you could edit your node-blog.tpl.php to look something like this:

    <?php if ($page): ?>
    My arbitrary HTML here which will not show up in teasers and only at the top of full blog pages
    <?php endif; ?>
    
    <div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
    <div class="item">
    <ul>
    <?php print $picture ?>
    
    <?php if ($page == 0): ?>
    <?php endif; ?>
    
      <div class="content clear-block">
    
        <li class="title"><h4><?php print $title ?></h4></li>
        <li class="photo"><a href="#"><img src="/<?php print $node->field_blog_image[0]['filepath']; ?>" /></a></li>
        <li class="desc"><?php print $node->content['body']['#value']; ?></li>
        <li class="link">
        <?php if ($teaser): ?>
        <a href="<?php print $node_url ?>" class="block-link">Read more</a> | <a href="<?php print $node_url ?>" class="block-link">Audio/Video</a> | 
        <?php endif; ?>
        <?php print $submitted; ?>
        </li>
        <div class="clear"></div>     
    
      </div>
    
      <div class="clear-block">
        <div class="meta">
        <?php if ($taxonomy): ?>
          <div class="terms"><?php print $terms ?></div>
        <?php endif;?>
        </div>
    
      </div>
    </ul>
    </div>
    </div>
    

    Edited since finding out you’re using the Blog module
    To display arbitrary HTML at the top of the listing of blog teasers just stick it at the top of page-blog.tpl.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.