Is there a way to move the next and previous forum topic navigation to the top of the node rather than the bottom?

Comments

scarer’s picture

michelle’s picture

Just an FYI, that's for 5.x. I haven't tried moving it in 6.x, just getting rid of it completely, but doing that is different than in 5.x

Michelle

x_ash_x’s picture

Hi!

The theme developer in the devel module is a huge help with this.

Basically what's happening is that the forum topic navigation is printing with the body of the node. You can change the order by not printing the default node body and instead separating the elements.

All you need to do is create a file called node-forum.tpl.php and then paste the following into the file:

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>">
  <div class="node-inner">
    <div class="content">
	<?php print $node->content['forum_navigation']['#value']; ?>
	<?php print $node->content['body']['#value']; ?>    
    </div>
  </div>
</div>

Hope that helps :)

scarer’s picture

thanks x_ash_x
however i am still to find out how to print the forumnextprevlinks before the title of the page. any suggestions? might have a play with the code above.

michelle’s picture

I was in the mood for a change of pace, so just added this to Advanced Forum. Here's an adapted version that you can put in your own site module:

/**
 * Implementation of hook_nodeapi().
 */
function MODULE_NAME_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'view' && !$teaser) {
    if (!empty($node->content['forum_navigation'])) {
      // Move the forum navigation to a seperate variable so it doesn't
      // get lumped in with the content.
      $node->forum_topic_navigation = $node->content['forum_navigation']['#value'];
      $node->content['forum_navigation'] = NULL;
    }
  }
}

What this does is takes the navigation stuff out of the content variable so it doesn't get stuck in with the content. It also assigns it to a new variable outside of the content array. This new variable is then accessable to any preprocess / template where the $node object is available as $node->forum_topic_navigation. That should let you move it wherever you want.

Michelle

scarer’s picture

when i tried the dev version of advanced forum i get a blank page. i wanted to see this in action. i don't really want to change the core forum module.

i tried adding the code:

/**
 * Implementation of hook_nodeapi().
 */
function advanced_forum_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'update' || $op == 'insert' || $op == 'delete') {
    // Update the cached statistics.
    advanced_forum_statistics_replies(TRUE);
  }

  if ($op == 'view' && !$node->teaser) {
    if (!empty($node->content['forum_navigation'])) {
      // Move the forum navigation to a seperate variable so it doesn't
      // get lumped in with the content.
      $node->advanced_forum_navigation = $node->content['forum_navigation']['#value'];
      $node->content['forum_navigation'] = NULL;
    }
  }
}

to the bottom of the advanced_forum.module file but it doesn't seem to like it.

michelle’s picture

I don't know why you'd be getting a WSOD... It's working fine AFAIK. At any rate, I wasn't suggesting hacking AF or core forum. I was suggesting you adapt the function I pasted before and put it in your own module.

Michelle

scarer’s picture

i was just using the core forum module so i don't have module to hack unfortunately.

michelle’s picture

You should have a site specific module to put snippets like this in. You can't do it without a module because themes can't use hook_nodeapi.

What update script are you talking about?

Michelle

scarer’s picture

i created a new module called forum_navigation and pasted this code in the forum_navigation.module file:

// $Id$
/**
* Implementation of hook_nodeapi().
*/
function forum_navigation_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'view' && !$teaser) {
    if (!empty($node->content['forum_navigation'])) {
      // Move the forum navigation to a seperate variable so it doesn't
      // get lumped in with the content.
      $node->forum_topic_navigation = $node->content['forum_navigation']['#value'];
      $node->content['forum_navigation'] = NULL;
    }
  }
}

i enabled the module and it still doesn't seem to work.

the update script - the drupal update.php file that you are prompted to run when you install the dev version of advanced_forum

michelle’s picture

Doesn't seem to work in what way? Does it give you errors? Are you not getting the new $node->forum_topic_navigation variable?

As for update.php... that's very strange. There shouldn't be any updates to run for AF if you're installing 2.x for the first time.

Michelle

scarer’s picture

i haven't tried uninstalling advanced forum and then re-installing. this error occurred when i replaced the module files with the dev files.

yeah it doesn't semm to be rendering the $node->forum_topic_navigation variable - i tried putting it in the node-forum.tpl.php and the page.tpl.php for my module and it doesn't show.

michelle’s picture

Wait, replaced _what_ module files? You said you were only using core forum, so I assume you were installing AF for the first time. If you mean you just replaced the 1.x files with the 2.x files and tried to update, yeah, you're likely to get a mess. The upgrade process isn't quite that simple.

I don't know why the variable wouldn't be getting set for you... Very strange. It's working fine in AF now. If you're running AF, make sure you have the option to turn on the navigation set. Other than that, I can't think of anything, sorry.

Michelle

scarer’s picture

thanks for all your help. and if i find a fix or what the problem is i'll post it up ;)

scarer’s picture

i ended up putting this code in the node-forum.tpl.php:

<div id="forumnextprevlinks">
<?php print $node->content['forum_navigation']['#value']; ?>
  <?php if ($submitted): ?>
    <span class="submitted"><?php print $submitted; ?></span>
  <?php endif; ?>
</div>

<div class="comment forum-comment comment-<?php print $row_class; print $comment->new ? ' comment-new forum-comment-new' : ''; ?>">
  <div class="comment-left">
  </div>

  <div class="comment-right">
    <div class="title"><?php print check_plain($comment->subject) ?></div>
    <?php if ($comment->new) : ?>
      <a id="new"></a>
      <span class="new"><?php print $new ?></span>
    <?php endif ?>
    <div class="content">
      <?php print $node->content['body']['#value']; ?>
      <br class="clear" />
      <div class="links"><?php print $links ?></div>
    </div>
  </div>
 
</div>
<br class="clear" />

still not getting the next previous links to forum topics before the page title though.

michelle’s picture

I don't know what to tell you anymore... The way I did it works. I put it at the bottom of the page like vB does, but you could put it anywhere you have access to the $node object. The code you have there doesn't make a lot of sense... It looks like you're putting the code for a comment in your node template. Keep in mind that the page title will print from page.tpl.php if there is a single node on the page.

That's all the more I can do here.

Michelle