Skip to:
Content
Pages
Categories
Search
Top
Bottom

Really Simple – Adding Link to theme – Need Help


  • kennibc
    Participant

    @kennibc

    Hello All,

    This should be fairly simple, but I cannot figure it out (or want to make sure I am doing it correctly) …

    I have three main icons I added to the buddypress-home theme: Your Profile, Create a blog, Create a Group.

    I would like to add links to those icons so that they take the user to the correct spot. I am unsure how to do this.

    Can someone please let me know what code I would need to add to the link so that it will take the user either to their profile page, create a new blog page, or the create a group page?

    I am going to feel really dumb when someone answers this because it is probably much simpler than what I was thinking. This is my first attempt at using BP and WPMU together and I am a little unsure of some things.

Viewing 11 replies - 1 through 11 (of 11 total)

  • Rich Spott
    Participant

    @richs0914

    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.


    kennibc
    Participant

    @kennibc

    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.


    kennibc
    Participant

    @kennibc

    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


    kennibc
    Participant

    @kennibc

    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.


    kennibc
    Participant

    @kennibc

    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>


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    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>


    kennibc
    Participant

    @kennibc

    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?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    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>


    kennibc
    Participant

    @kennibc

    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.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Awesome! Good job! Gonna green light this one.

    You’re welcome. ;)


    jeff-sayre
    Participant

    @jeff-sayre

    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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Really Simple – Adding Link to theme – Need Help’ is closed to new replies.
Skip to toolbar