Add .tpl for customizing repeated node after first page

LasseP - February 2, 2008 - 23:14
Project:Advanced Forum
Version:5.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

At first: Sorry if this is already done, and just happening to me, because i changed so much in the advforum themes.

When you go to a follow up page of a topic, the topic is displayed at the top. This is not usual in other forum software, and i didn't want that, too.
But i thought, maybe it's usefull to let the user decide if he wants to see the first post on top of the page.

So i changed the following things:

In advanced_forum.module

<?php
 
if ( ! $page_number ) {
   
$page_number = 0;
  }
 
// ADDED THIS LINE
 
$vars['page_number'] = intval($page_number); 
?>

In forum-thread.tpl.php

<?php
<?php  if($page_number > 0){   ?>

    <script type="text/javascript">
     function toggleOriginalText() {
       $(document.getElementById("top-post-teaser")).toggle();
       $(document.getElementById("top-post-complete")).toggle();
       $(document.getElementById("read_more")).toggle();
       $(document.getElementById("read_less")).toggle();
     }
    </script>
    <div  class="top-post-small">
      <span class="submitted">Posted on <?php print "". $date ?> by <?php print $name ?></span>
      <div id="top-post-teaser"><?php print node_teaser($node->body); ?></div>
      <div id="top-post-complete"><?php print $content  ?></div>
      <span id="read_more" class="node_read_more"><a href="javascript:toggleOriginalText();"><?php print t("Show full text"); ?></a></span>
      <span id="read_less" class="node_read_more"><a href="javascript:toggleOriginalText();"><?php print t("Hide full text"); ?></a></span>
    </div>
    <?php
 
} else {
 
?>

  // ADD standart code for top post here
?>

Now, the ordinary top post will be exchanged with the code above. Offering a teaser, and a full content display. It's up to you how to design it.
I wanted it very clean and without much design around it, so i added the following to
advanced-forum-structure.css

/* TOP-POST-TEASER */
.top-post-small {
  width: 95%;
  padding: 2px;
  margin: 2em auto 0 auto;
  color: #444;
  font-style: italic;
  font-size: 0.8em;
  border: 1px dotted #ddd;
}

#top-post-teaser p {
  padding: 0;
}

#top-post-complete {
  display: none;
}
#read_less {
  display: none;
}

Most of this is still a rough cut version. Maybe someone would have got a better solution, or find some bugs in my version.

#1

Michelle - May 16, 2008 - 13:25
Title:Exchange full node display on top of follow up pages with teaser» Add .tpl for customizing repeated node after first page

Morbus just gave me a great idea for this:

if ($_GET['page'] > 0) { $vars['template_file'] = 'null'; }

I'll replace "null" with a more suitable name but the idea is that, if left empty, the .tpl will wipe out the node display on following pages. But this also leaves open the option to put stuff in it like a teaser or give it special classes. Could also put LasseP's idea in it. I think this will give site admins the most flexibility.

Michelle

#2

Michelle - May 28, 2008 - 02:11
Status:active» fixed

In the commit queue for both 5 and 6.

Michelle

#3

Anonymous (not verified) - June 11, 2008 - 02:11
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.