Skip to:
Content
Pages
Categories
Search
Top
Bottom

field excerpt to show in members page


  • joshreid
    Participant

    @joshreid

    Hi its been a while since i did any of this.
    I am trying to show a field excerpt in the members page of my site.
    Is there a plugin for this or is there a setting im missing.
    Thanks for your time

Viewing 25 replies - 1 through 25 (of 29 total)

  • Venutius
    Moderator

    @venutius

    Typically the way to do this would be to overload the members page (buddypress/bp-template/bp-theme/members/members-loop.php) and at your code to display the field excerpt.


    joshreid
    Participant

    @joshreid

    Hi Venutius thanks for that i will give it a try


    joshreid
    Participant

    @joshreid

    Thanks for showing me the right place, I am shore that it is the right place. But I having trouble finding the right code for it. Ive tried a few and they show up in the area but its the actual code not the data. I am wondering if i have the wrong field name? I have changed the field name to 2 as a way to make it easier to work. function bp_custom_member_list_xprofile_data( $2 ) {

    echo bp_custom_get_member_list_xprofile_data( $2 );

    }

    function bp_custom_get_member_list_xprofile_data( $2 ) {

    global $site_members_template;

    return xprofile_get_field_data( $field, $site_members_template->member->id );

    }` but I am not sure. This code shows up where i want the field 2 excerpt to show. Thanks


    Venutius
    Moderator

    @venutius

    It’s a template file so any PHP that you add needs to have <?php and ?> tags surrounding it, dod you do that?


    joshreid
    Participant

    @joshreid

    Yes when I do that the members part of the page just stays a please wait.
    the post i got this code from says underneath that if you need checking ad this

    <?php if ( $company = bp_custom_get_member_list_xprofile_data('Company') ) : ?>
    
    <p><?php echo $company ?></p>
    
    <?php endif; ?>

    and if you don’t need checking add this
    <p><?php bp_custom_member_list_xprofile_data('Company') ?></p>


    joshreid
    Participant

    @joshreid

    it seams to stop the file once i add the <?php ?> do I need to create a div class it seams the other content has there own div?


    joshreid
    Participant

    @joshreid

    i tried changing the code still nothing please see if maybe I am doing somthing wrong.

    <?php if ( bp_nouveau_member_has_meta() ) : ?>
    <p class=”item-meta last-activity”>

    <?php if ( bp_has_profile(‘profile_group_id=2’) ) : ?>
    <?php bp_nouveau_member_meta(); ?>
    </p><!– #item-meta –>

    <?php endif; ?>`

    <?php if ( bp_has_profile(‘profile_group_id=2’) ) : ?>`
    is the new code i was trying but is seams every time i put any php code in there it frezzes that part of the page. Maybe an array or I dont know. thanks


    Venutius
    Moderator

    @venutius

    Please put your code in backticks ` that way it’s a lot easier to read.

    From what I can see there’s a few errors if your code. for example don’t break a <p> element with an if sttement. Otherwise you will end up with broken html. Also an if statement with a : always needs to be completed with an endif. as you’ve written it above you have an if and no endif. Also your code keeps changing. What exactly are you trying to do? Display a profile field? Can you confirm the field id?


    joshreid
    Participant

    @joshreid

    Oh sorry I thought I added the backticks.
    Yes sorry for the changes Im just trying to work out the problem.
    I will explain better what I am trying to do.
    On my website when a member fills out there profile or edits it one of the fields is a description field.

    Then when someone goes to the members page, the members profiles show up with the profile pic (and you can scroll down the page getting a quick look at the profiles) but there is no except about the profile. I want that description field to show up individually for each members description.

    No I can’t confirm the field id, I tried looking for it but can’t find it. If I do a page inspect I can see field_2 but alot of other text after it. But I am not sure I am right about that, I was just going of the field name.


    Venutius
    Moderator

    @venutius

    If you go to Users>>Profile Fields and hover your mouse above the edit button for the field you cna see the field id in the url. it sounds like the id is 2 but could you confirm?


    joshreid
    Participant

    @joshreid

    Yes I can confirm it is 2. id=2 is the end of the url


    Venutius
    Moderator

    @venutius

    Ok you could insert the following around line 43 of the members-loop.php:

    <?php $value = xprofile_get_field( 2, bp_get_member_user_id(), true ); ?>
    <?php $value = $value->data->value; ?>
    
    <?php if ( $value ) : ?>
    	<p class="item-details">
    	<?php echo $value; ?>
    	</p><!-- #item-details -->
    <?php endif; ?>
    

    Mae sure you remove any other code you have added.


    joshreid
    Participant

    @joshreid

    Thanks I have inserted it but its still not working. All the members come up but not the field 2 excerpt.


    Venutius
    Moderator

    @venutius

    What sort of field is it? I’m assuming it’s just a text field


    joshreid
    Participant

    @joshreid

    I have opened a new members loop file in subline text to see if there is any thing that i did wrong but i can’t see any changes


    joshreid
    Participant

    @joshreid

    its is a multi-line text area. i can change it to see if that works maybe but then they don’t have enough area to text


    Venutius
    Moderator

    @venutius

    That should display it then, the codes good for text and textarea fields. Not sure what else to suggest.


    joshreid
    Participant

    @joshreid

    yeah I just tried changing it, didn’t . Oh no. Ok maybe I will just check the code a few more times. would spaces in the code make it not work?


    joshreid
    Participant

    @joshreid

    Thanks very much for your help anyway. Ill keep trying, I always get myself in these situations


    Venutius
    Moderator

    @venutius

    Ah hold on, seems we need to find a different way for nouveau, I’ve just tested it and it does not work. That method would work for Legacy but apparently not for Nouveau. Let me do some digging.


    Venutius
    Moderator

    @venutius

    Ah hold on there was a typo in my code. on my system it’s not working but showing the same data for all users. I’ve updated the code, give it a try see how it works for you.


    joshreid
    Participant

    @joshreid

    oh ok ill try now


    Venutius
    Moderator

    @venutius

    I’ve updated it again, it should now work


    joshreid
    Participant

    @joshreid

    Yes the same with me its coming through but all the same.


    Venutius
    Moderator

    @venutius

    Yep the latest code fixes that

Viewing 25 replies - 1 through 25 (of 29 total)
  • You must be logged in to reply to this topic.
Skip to toolbar