Node template for node teaser blog

I am trying to create a node teaser template to display all the tiaras on blogs. For the tpl page, I have a page-blogs.tpl.php For a node tpl blog, I have a node -blog.tpl.php (This loop loops around to display all the blog tiaras) Now, how to create a node template to surround node tiaras? My URL for a page with all blog tiaras: / blogs / eric My URL for a page with an example blog entry: / blogs / eric / test-blog-1 I need a node template that I can use for all blog pages. I tried using node -blogs-teaser.tpl.php for individual teaser nodes and node -blog.tpl.php for an external node blog template, but that didn't work.

Here is what I have in the 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>

thank

UPDATE: I added the page preprocessor function to 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;
        }
    }
    //---- 
}
+3
1

, "", node -blog.tpl.php , . $teaser TRUE node -blog.tpl.php, Drupal , $page ​​ TRUE, node ( FALSE, node ). node -blog.tpl.php, , , HTML, . node -blog.tpl.php :

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

, , - node -blog.tpl.php, . . Drupal , Wordpress.

, /blogs/eric, Views. "" , , "".

HTML node , node -blog.tpl.php, :

<?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>

, , Blog HTML , -blog.tpl.php

+6

Source: https://habr.com/ru/post/1761164/


All Articles