Firstly for all you code geniuses out there. I'm sorry. This is probably a really really basic and dumb question. But I'm going to ask it anyway as it'll help me understand some things more.

I have the following code in a block:

global $user;
if ($user->uid) {
    print '<b>Welcome back '.$user->name.'!</b>                ';
}
global $user;
print l("Go To Your Blog", "blog/" . $user->uid);

This basically puts in the block "Welcome back user! Go To Your Blog"

(User is obviously the actual user name and Go To Your Blog is a link to the users blog).

My question is how do I alter this code so that each section is on a distinct seperate line?

So rather than "Welcome back user! Go To Your Blog"

I want:

Welcome back user!

Go To Your Blog

Effectively there is a line break between the two messages.

It's just a matter of looking neater on the page but I have no clue how to do it.

Any guidance gratefully received.

Thanks

Comments

pbarnett’s picture

print '<br />' . l("Go To Your Blog", "blog/" . $user->uid);

Pete.

Allthegearnoidea’s picture

Ha ha... Simple but effective... Damn it I feel foolish.

At least I know how to do it now :-)

Thanks Pete.

Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk

sidharth_k’s picture

You don't need to declare the variable twice. Only once is okay... at the top.

Allthegearnoidea’s picture

...the variable?

Thanks. I should tidy it all up a bit really.

Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk

sidharth_k’s picture

Hope this helps

pbarnett’s picture

<?php
global $user;
if ($user->uid) {
    $name = $user->name;
    $id = $user->id;
    print "<b>Welcome back {$name}!</b><br />" . l('Go to your blog', "blog/$id");
}
?>

Pete.

Allthegearnoidea’s picture

Thanks guys.

Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk

Allthegearnoidea’s picture

The above code actually takes the user to the page with all blogs not the users specific blog.

I thought I could amend this myself, but when I tried it it didn't work!

So for now I'm sticking with my untidy version :-)

Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk

pbarnett’s picture

My mistake; try this :-

<?php
global $user;
if ($user->uid) {
    $name = $user->name;
    $id = $user->uid;
    print "<b>Welcome back {$name}!</b><br />" . l('Go to your blog', "blog/$id");
}
?>

Pete.

Allthegearnoidea’s picture

all works fine now. Thanks for posting, this whole thing has allowed me to understand some coding a little more. That's either a good thing, or a very dangerous thing :-)

Thanks again.

Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk