Help me out guys,
I would like to know if there is anyway to override the function where it generates the node teaser list on the front page. I can't even identify where this happens!
what i'm trying to do is:
create 3 columns for the teaser list, but after every row (of 3 teasers), i want to put 3 more custom divs in between. I use for a custom Ajax module where I expand the the full node right there on the front page! (yes this already works fine, tell me if anybody is interested in the code).
But now i face a problem on my site. I know about node.tpl.php, where you can customize every teaser node, but because as far as i know, it is highly cumbersome to try to add something every 3 teaser nodes. It helps if i try to visualize what i'm trying to do abit ...
000 <---- 3 node teasers
-----
___ <---- jQuery magic, those top three nodes expand here! 3 divs of (div class=expandnode-$nid)
000 <---- 3 more teasers
-----
___ <---- 3 divs of (div class=expandnode-$nid)
00 <---- in this example, 2 more last teasers
-----
___ <---- 2 divs of (div class=expandnode-$nid)
After much rummaging around, i managed to find a klunky partial solution, by customizing node.tpl.php and template.php. But the problem with this solution is that I can't get the last 2 divs to show, because it will only flush out the divs after every 3 teasers, and the last row only has 2.
this is my code:
template.php
<?php
function _malayaland_current_col() {
static $count;
$count = is_int($count) ? $count : 0;
$count++;
if ($count==4) { $count = 1; };
return $count;
}
function _malayaland_expandnode($op, $nid=0) {
static $divstr;
switch ($op) {
case "append":
$divstr .= "<div id=expandnode-$nid></div>";
break;
case "flush":
$tempdivstr = $divstr;
$divstr = "";
return $tempdivstr;
break;
}
}
?>
node.tpl.php
<div class="entry<?php print ($sticky) ? " sticky" : ""; ?>">
<?php if ($page == 0): ?>
<?php
$count = _malayaland_current_col();
?>
<div class="col<?php print $count ?>">
<h2><a href="<?php print $node_url ?>" rel="bookmark" title="Permanent Link to <?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php print $content ?>
<?php if ($links): ?>
<p class="info">Posted in <?php print $terms ?> <?php print $links ?></p>
<small><?php print $submitted ?></small>
<?php endif; ?>
<?php if ($page == 0) { print '</div>'; };?>
<?php
_malayaland_expandnode("append", $node->nid);
if ($count==3) {
print _malayaland_expandnode("flush");
};
?>
</div>
In fact, not only doesn't this code fully work, but I think this is not the right direction I'm going in. Its very inelegant.
Is there a way to customize the function where it builds this teasers list? Or least tell me where I can find it so that I can copy and build my function instead ...
Comments
teaser mucking
Man, I hear ya. I found this incredibly helpful:
http://drupal.org/node/133236
HTH!