if you don’t know what you’re doing…you could always go into bp-core-adminbar.php and take the code from there and just apply it where you want it.
bp-core-adminbar.php (in bp-core) has all three of those links already.
Thanks Richs0914…
I did go in there, but it had echo … something or other.
I was hoping to fins something like
><img> My Icon Image</img>
The “something I don’t know here” is where I am having trouble. The adminbar.php has the links as part of a function I believe with echo before them.
Any ideas, I cant get the links to work.
Here is what I have for the links, but it is not working:
<a href="<?php echo ' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog' '; ?>"><img src="<?php bloginfo('template_directory'); ?>/images/createblog.png" alt="Create a Blog" hspace="4" align="right" /></a>
I am no coding guru, can someone please help me with creating 3 links for images:
One that takes you to the create a blog page
One for the create a group page
One for the users profile
Here is a link to a photo of my theme and you will notice the 3 buttons in the upper right. That’s where I need to add these links.
http://blog.dearbornschools.org/webmaster/files/2009/03/engagehome1.jpg
Any help would be much appreciated. I am about 3 links away from introducing this to students and letting teachers know they can now make it a requirement that the student maintain a website/blog.
I am also trying this with no luck, but I think I am closer… Maybe this is a harder question than I thought since there is no quick reply.
<a href="http://engage.dearbornschools.org/members/<?php echo ' . $bp->loggedin_user->id' ; ?>/blogs/create-a-blog"><img src="<?php bloginfo('template_directory'); ?>/images/createblog.png" alt="Create a Blog" hspace="4" align="right" /></a>
Try…
<a href="<?php echo get_option('home') ?>/<?php echo MEMBERS_SLUG ?>/<?php echo $bp->loggedin_user->id; ?>/blogs/create-a-blog">
<img src="<?php bloginfo('template_url'); ?>/images/createblog.png" alt="Create a Blog" hspace="4" align="right" />
</a>
That code is much better, but returns this link in the page:
http://engage.dearbornschools.org/members//blogs/create-a-blog
It’s not pulling the user name.
Any suggestions?
Lets try this? Might be a step backward but I’ll cross my fingers…
<a href="<?php echo $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">
<img src="<?php bloginfo('template_url'); ?>/images/createblog.png" alt="Create a Blog" hspace="4" align="right" />
</a>
THANK YOU JAMES!
It got me very close to what was missing. Here is the proper code (I assume since it works)
<?php global $bp; ?>
<a href="<?php echo $bp->loggedin_user->domain; ?>blogs/create-a-blog">
<img src="<?php bloginfo('template_url'); ?>/images/createblog.png" alt="Create a Blog" hspace="4" align="right" />
</a>
I had to add the global and get the $bp. Then the call for loggedin_user->domain did the trick with the hard code path following it.
Thanks James. You got me going in the proper direction. Hopefully others will find this useful when modifying/creating BP templates.
Awesome! Good job! Gonna green light this one.
You’re welcome.
Hey kennibc-
I’m glad jjj got you down the path.
I assume you’re placing this code in the header.php file. The reason that you need to set $bp as global is that without it, a call to the $bp object is out of scope–it has no way to reference the object’s fields.
Here’s another way to accomplish your clickable image links. This way pulls in the user’s name and not the user’s id.
<?php global $bp; ?>
<a href="<?php echo bp_core_get_userurl($bp->loggedin_user->id); ?>blogs/create-a-blog" title="hi" ><img src="<?php bloginfo('template_url'); ?>/images/createblog.png" alt="Create a Blog" /></a>
Two final notes:
First, I removed the hspace=”4″ align=”right” attributes from the image tag. You don’t need them. Instead, position the images using CSS.
Second, I included the title tag within the anchor tag. Replace the text with whatever you want it to say. Although it is a matter of choice among coders, in my opinion it is wise to make a practice of using the title tag. It is an accessibility aid on links and it allows browsers to pop up a nice tooltip when a user positions their browser over an image.