Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Theming Questions

  • @madyogi

    Participant

    I am in the process of designing a custom theme for a website running on WPMU 2.8.4 with an install of BuddyPress 1.1.1. I don’t have much need for the multi-user aspect of WPMU, but went with this as my “CMS” because of the social networking components BuddyPress can bring to the table. At least in the near term I will only be using one blog with a pretty extensive home-page involving some content managed through WordPress and some pages that are essentially independent.

    So I have built a theme for the main WordPress blog completely from scratch. Now I’m scratching my head as to how I’m going to integrate the BuddyPress features I need into the areas of the theme where I need them. My strategy so far has been to take all the files in the BuddyPress parent theme that weren’t present in my custom theme, move them into my custom theme folder, then dissect the core template files from the BuddyPress parent theme (header.php, home.php, etc.), extracting the BuddyPress elements, and placing them into my template files where necessary.

    Here is the current result – http://boxmediasolutions.com/wpmuTest/

    It seems to be going along okay at the moment, but I’m thinking there has to be a better way to go about this, so I have a couple of questions for the community if anyone cares to offer advice.

    1) Is there an easier way to do this kind of thing that already has good documentation that I’m just overlooking?

    2) Can I move the div#search-login-bar out of the header, placing it essentially atop the content div in only a few specific pages (ie – the ones that involve connecting with the community)?

    3) Is there documentation somewhere explaining the template hierarchy of WPMU and BuddyPress, how they interact, and what is exactly being called for by commands like do_action( ‘bp_before_search_login_bar’ ), do_action( ‘bp_after_search_login_bar’ ), do_action( ‘bp_before_header’ ), etc?

    4) Can commands like the ones mentioned in question 3 be reversed, like calling for the before/after search login bar after the before/after header actions?

    I am quite comfortable editing/developing WP themes and template files, though I am completely new to BuddyPress and WPMU, and I am not really well versed in PHP coding, just to give you a bit of background.

    Thanks a ton in advance for any advice!

Viewing 7 replies - 1 through 7 (of 7 total)
  • @anonymized-96400

    Inactive

    The best way to start with a theme for BP is to start off with the bp-default theme. Then copy files across from the bp-sn-parent theme if you need to modify a file. If not, then you can leave that file in bp-sn-parent, cause WP will get that automatically for you.

    Of course, you can add all the functions later. The codex here is a great starting point on what functions are available to you. You can also go through the bp-sn-parent theme and have a look what’s in there and move it across, if you don’t want to use a parent/child theme structure.

    You can place div#search-login-bar anywhere you like.

    do_action functions cannot be reversed. They happen at exactly that spot in the template files. There’s so many, though, that you won’t have a problem finding one that suits your needs. Basically, you can write some custom functionality and add that to a certain hook by calling the add_action function. Here’s an example.

    Somewhere in a template you might have this:

    do_action( 'your_action_name' );

    Then in your theme’s functions.php file you could put the following:

    function your_function_name()
    {
    //some stuff happens here
    }
    add_action( 'your_action_name', 'your_function_name' );

    That’s basically it. Sometimes the action passes along a variable with which you can then work.

    Hope this helps you along a bit. The codex at wordpress.org is pretty extensive as well and you’ll find loads of stuff on actions.

    @madyogi

    Participant

    Thanks so much for the reply, travel-junkie! Very helpful. One question, though:

    You said:

    The best way to start with a theme for BP is to start off with the bp-default theme. Then copy files across from the bp-sn-parent theme if you need to modify a file. If not, then you can leave that file in bp-sn-parent, cause WP will get that automatically for you.

    From what I’ve read about parent/child relationships, the only files that are functional in child themes are style.css and functions.php. Has this changed in 2.8? Am I able to override parent template files by placing a revised template file in my child theme’s directory?

    @madyogi

    Participant

    Secondarily, regarding the actions in BuddyPress, what are the effects of leaving out an action that is found in the default theme? Say, for example, leaving out:

    <?php do_action( 'bp_before_search_login_bar' ) ?>

    and then

    <?php do_action( 'bp_after_search_login_bar' ) ?>

    Finally is there some reliable documentation detailing what these actions actually do within the theme/template/plugin?

    Thanks again!

    @anonymized-96400

    Inactive

    Most of the do_actions you find within the default theme don’t have any actions hooked to them. I guess they are mostly there for plugins and for child themes.

    Yep, any template file you copy from the parent theme to the child theme overrides the one in the parent theme. With all these actions, though, you won’t need to do that much. Say you want to add a terms of service checkbox to your register page. So, rather than copying registration/register.php to your child theme and adding the checkbox manually, for example, you could just write a function in your child theme functions.php that hooks into a do_action call at the end of the form and adds a terms of service checkbox for you.

    Makes it really easy updating the parent theme.

    To find out what an action does, if anything, just copy the name of the action and do a search with it in the buddypress plugin folder. That should list you all functions that are hooked to that action (add_action).

    @madyogi

    Participant

    Alright, this is starting to congeal. Only thing is, I”m about 80% confident with what you’re saying regarding the creation of actions in the functions.php file and those actions hooking into a do_action call in the parent theme.

    2 questions:

    1) If I create an action in the child functions.php that does not exist in the various templates of the parent theme, is it better practice to fiddle with the template file(s) of the parent theme, adding the do_action call there, or to move the template file to the child theme before making any changes?

    2) Do you or anyone else have any suggestions for references a semi-savvy-newbie might use to gain a more complete understanding of how to write actions in the functions.php file? I assume there’s some fairly complete documentation in the wordpress codex, but perhaps there’s a link or two to some nice tutorial-type blog entries? I probably need to spend some more time with PHP coding anyway :-)

    Thanks everybody.

    @anonymized-96400

    Inactive

    You should never modify the parent theme. When you update buddypress and with it the parent theme all your modifications will be lost.

    A good tutorial source for PHP and WP is net.tutsplus.com. And of course the codex here and on wordpress.org. As for writing functions, you do that exactly like I referenced in the comment above.

    @victor_moura

    Participant

    Hi Travel-Junkie!

    The checkbox to indicate acceptance to the terms of service is exactly what I want to do.

    However, I am a total noob in understanding the programming involved (like “actions”) for example.

    Do you have a recommendation? Should i look for a plugin for this?

    Or a link where the concepts you refered to are more easily understandable by me?

    (sorry, I’m a recent “ning-orphan” trying to find my way around Buddypress)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Theming Questions’ is closed to new replies.
Skip to toolbar