Forum Stats

Forum Stats

  • Visitor
  • 585
  • 1969-12-31
  • Offline
  • Mon, 05/12/2008 - 16:54

Great forum!! Looks like you've helped a ton of people...

I have advanced forum setup and running - my members love it so much better than the default forum that comes with drupal..

I am trying to get the user stats setup....I tried a code for user post count and offline/online status but it simply places it next to the users id..

how can I get all this information to be placed in a block on the left of the post like you guys have here?

my forum is here..http://czeepoker.com/?q=forum


phptemplate_variables

  • Michelle's picture
  • Michelle
  • 436
  • 2007-05-13
  • Offline
  • Mon, 05/12/2008 - 19:42

Looks like you don't have the call in _phptemplate_variables() correct. Without that, the actual forum posts are not processed correctly.

Michelle


ok is there something I can

  • Visitor (not verified)
  • 585
  • 1969-12-31
  • Offline
  • Mon, 05/12/2008 - 21:28

ok is there something I can do to fix this?


Yeah...

  • Michelle's picture
  • Michelle
  • 436
  • 2007-05-13
  • Offline
  • Mon, 05/12/2008 - 22:32

Sure, you can put the correct code in. ;)

If you want help with that, I'm going to need more to go on. Like your _phptemplate_variables function so I can see what's wrong. Otherwise, my SWAG is that you are returning array() from the function instead of $vars.

Michelle


ok, should i be copying and

  • Visitor (not verified)
  • 585
  • 1969-12-31
  • Offline
  • Tue, 05/13/2008 - 13:43

ok, should i be copying and pasting you something?

sorry I am a little code illeterate:)


Yes

  • Michelle's picture
  • Michelle
  • 436
  • 2007-05-13
  • Offline
  • Tue, 05/13/2008 - 21:53

I need to see your _phptemplate_variables() in order see what's wrong.

Michelle


ok.. i found this in the

  • Visitor (not verified)
  • 585
  • 1969-12-31
  • Offline
  • Wed, 05/14/2008 - 11:23

ok.. i found this in the template.php folder in my theme folder - not sure if this is what you need...if not can you point me to the file that contains the function you need? thanks

function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
// Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out.
case 'page':
// get the currently logged in user
global $user;


That's it

  • Michelle's picture
  • Michelle
  • 436
  • 2007-05-13
  • Offline
  • Wed, 05/14/2008 - 12:27

Well, the top of it anyway... Did you paste the advforum function call farther down? I need to see the whole thing to make sure you pasted the code properly and that it's returning the right variable. While the advforum docs say to put it at the top to make it easier, it's fine if you put it at the end, as long as it's outside of that switch.

Michelle


this is my template.php page

  • Visitor (not verified)
  • 585
  • 1969-12-31
  • Offline
  • Wed, 05/14/2008 - 12:52

this is my template.php page code - i had my host install advanced forum for me as I am not too experienced with drupal/coding....is there anyway we can communicate via a messenger?

<?php
function _phptemplate_variables($hook, $vars = array()) {
  switch (
$hook) {
   
// Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out.
   
case 'page':
     
// get the currently logged in user
     
global $user;
     
     
// An anonymous user has a user id of zero.     
     
if ($user->uid > 0) {
       
// The user is logged in.
       
$vars['logged_in'] = TRUE;
      }
      else {
       
// The user has logged out.
       
$vars['logged_in'] = FALSE;
      }
     
     
$body_classes = array();
     
// classes for body element
      // allows advanced theming based on context (home page, node of certain type, etc.)
     
$body_classes[] = ($vars['is_front']) ? 'front' : 'not-front';
     
$body_classes[] = ($vars['logged_in']) ? 'logged-in' : 'not-logged-in';
      if (
$vars['node']->type) {
       
$body_classes[] = 'ntype-'. copyblogger_id_safe($vars['node']->type);
      }
     
     
//  This following bit of code sets flags for if sidebars exist. If you
      //  have multiple regions in the sidebars, add them to the conditional.
      //  The first is for the left side and the second for the right.
     
if ($vars['search_box']||$vars['main_supplements']) {
       
$leftBar = true;
      }
     
      if (
$vars['secondary_supplements']) {
       
$rightBar = true;
      }
     
     
      switch (
TRUE) {
          case
$leftBar && $rightBar :
             
$body_classes[] = 'sidebars';
              break;
          case
$leftBar :
             
$body_classes[] = 'main-sidebar';
              break;
          case
$rightBar :
             
$body_classes[] = 'secondary-sidebar';
              break;
      }
     
// implode with spaces
     
$vars['body_classes'] = implode(' ', $body_classes);
     
      break;
     
    case
'node':
     
// get the currently logged in user
     
global $user;

     
//  set a new $is_admin variable
      //  this is determined by looking at the currently logged in user and
      //  seeing if they are in the role 'admin'
     
$vars['is_admin'] = in_array('admin', $user->roles);
     
     
$node_classes = array('node');
      if (
$vars['sticky']) {
         
$node_classes[] = 'sticky';
      }
      if (!
$vars['node']->status) {
         
$node_classes[] = 'node-unpublished';
      }
     
$node_classes[] = 'ntype-'. copyblogger_id_safe($vars['node']->type);
     
// implode with spaces
     
$vars['node_classes'] = implode(' ', $node_classes);
     
      break;
     
    case
'comment':
     
// we load the node object that the current comment is attached to
     
$node = node_load($vars['comment']->nid);
     
// if the author of this comment is equal to the author of the node, we set a variable
      // then in our theme we can theme this comment differently to stand out
     
$vars['author_comment'] = $vars['comment']->uid == $node->uid ? TRUE : FALSE;
      break;
  }
 
  return
$vars;
}
?>

[Edited down to just the function in question]


No function call

  • Michelle's picture
  • Michelle
  • 436
  • 2007-05-13
  • Offline
  • Wed, 05/14/2008 - 13:52

No, I don't use messenger. I answer support questions in between taking care of the kids when I have time.

Ok, I see the problem. Your host didn't follow the module's installation instructions. If you're going to run a Drupal site, it's in your best interest to learn Drupal rather than having your host do everything or you're likely to run into this again. Running alpha modules when you don't know what you're doing isn't the best idea in general. Luckily, this problem is pretty easy to fix. Right after function _phptemplate_variables($hook, $vars = array()) { and before switch ($hook) { add these three lines (NOT the php tags):

<?php
 
if (module_exists('advanced_forum')) {
   
$vars = advanced_forum_addvars($hook, $vars);
  }
?>


thanks michelle - works now

  • Visitor (not verified)
  • 585
  • 1969-12-31
  • Offline
  • Thu, 05/15/2008 - 15:55

thanks michelle - works now :)


Post new comment
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options