This may not be the place to ask this, but I was wondering if someone can help me with the Blossom theme. I reported an issue with blossom development, but maybe someone here knows a quick fix.

I need to customize page specific block visibility; it works when I switch themes so I know my urls are right, etc. It must be theme specific. Blossom uses a custom user login, so maybe there is a problem somewhere here?

/********* USER LOGIN FUNCTION ****************************/

function flower_user_bar() {
  global $user;                                                               
  $output = '';

  if (!$user->uid) {    
 
  $output .=t('<p class="welcome">Welcome, Guest.<br />Please login or <a href="'.$base_path.'user/register">register</a>.<br /><a href="'.$base_path.'user/password">Request Password</a></p>');
                                                        
    $output .= drupal_get_form('user_login_block');                           
  }                                                                           
  else {                                                                      
    $output .= t('<p class="user-info">Welcome !user.</p>', array('!user' => theme('username', $user)));
 
    $output .= theme('item_list', array(
      l(t('Your account'), 'user/'.$user->uid, array('title' => t('Edit your account'))),
      l(t('Logout'), 'logout')));
  }
   
  $output = '<div id="user-bar">'.$output.'</div>';
     
  return $output;
}

Also, is it unusual to call the function in page.tpl.php?

print flower_user_bar()

Any advice is appreciated!!! Thank you,

Shawn

Comments

Jeff Burnz’s picture

Not wanting to state the obvious but the function call is hard coded into page.tpl.php so why would adjusting block visibility have any effect?

Take the function call out of page.tpl.php and print in a block (all block, set input format to PHP), then use set the visibility settings on that.

Ashoka’s picture

Here is the block.tpl.php

<?php if($block->subject=='User login'){ ?>
<?php }else{?>
<div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
    <h4><?php print $block->subject; ?></h4>
    <div class="content"><?php print $block->content; ?></div>
 </div>
<?php }?>

Pretty novice php coder. Removing hard coded "print flower_user_bar()"...

So adding the function call to block.tpl.php, might cause desired results? I don't know why blossom creator designed if so... New block.tpl.php:

<?php if($block->subject=='User login'){ print flower_user_bar() ?>
<?php }else{?>
<div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
    <h4><?php print $block->subject; ?></h4>
    <div class="content"><?php print $block->content; ?></div>
 </div>
<?php }?>

Much appreciated and thanks for quick reply btw...

Jeff Burnz’s picture

Nope, that all wrong, scrap the lot of it. What I meant was...

1. Create a new block from the Drupal blocks configuration page (admin/build/block/list), click the "Add Block" tab.

2. You probably want to set the title to <none>

3. Paste in the function call <?php print flower_user_bar() ?>, set the input format to PHP (you may need to enable this in Modules if you have not already).

4. Set your visibility settings.

Now what you want to do is create a block template using the ID of the block; your new block will have an id like block-block-1, so copy/paste the default block template and call it block-block-1.tpl.php, now delete everything in your new template EXCEPT for one line: <?php print $block->content ?>, this should clean up the HTML a bit and probably make it easier to theme.

You can find this id by enabling the block and viewing the source code, usually most themes print this id on the main block wrapper.

Upload the template, clear the theme registry and you are good to go.

Ashoka’s picture

Works at first attempt! I'll spend some time formatting, but that is a great work around for the problem. I suppose blossom designers had a reason for hard coding the login box... Thanks again,

Shawn

Jeff Burnz’s picture

theres some real weird shit going on with comments here... got me stumped :)