【问题标题】:How to customize buddypress groups如何自定义 buddypress 组
【发布时间】:2014-06-11 12:32:24
【问题描述】:

我正在设置一个 Wordpress 页面,并且我正在尝试自定义 buddypress 组的外观。我希望它们水平显示而不是垂直显示。谁能指导我完成?

<div class="container-fluid">
    <div class="row">
    <div class="groups-list" class="item-list" role="main"></div>

            <?php while ( bp_groups() ) : bp_the_group(); ?>

            <?php bp_group_class(); ?>
        <div class="item-avatar">
            <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
        </div>

        <div class="item">
            <div class="item-title"><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a></div>
            <div class="item-meta"><span class="activity"><?php printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); ?></span></div>

            <div class="item-desc"><?php bp_group_description_excerpt(); ?></div>

            <?php do_action( 'bp_directory_groups_item' ); ?>

        </div>
        </div>
        </div>

【问题讨论】:

    标签: php css customization buddypress


    【解决方案1】:

    您是否尝试将循环的结果包装在 div 中并使其浮动?我认为使用 css 只要你清除浮动之后就可以了。像这样的:

    <div class="group-container">
    <?php while ( bp_groups() ) : bp_the_group(); ?>
    
    <?php bp_group_class(); ?>
        <div class="float-left">
        <div class="item-avatar">
            <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
        </div>
        <div class="item">
            <div class="item-title"><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a></div>
            <div class="item-meta"><span class="activity"><?php printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); ?></span></div>
            <div class="item-desc"><?php bp_group_description_excerpt(); ?></div>
    
            <?php do_action( 'bp_directory_groups_item' ); ?>
    
        </div>
    <?php endwhile; ?>
        <div class="clear-floats"></div>
    </div>
    

    如果要添加引导类,则必须在循环外添加行类(通过组),然后在每个组的循环内添加 col 类。但我认为您必须将所有这些包装在一个容器中。

    【讨论】:

    • 非常感谢您的回答!
    【解决方案2】:
    /**
     * The bp_is_active( 'groups' ) check is recommended, to prevent problems 
     * during upgrade or when the Groups component is disabled
     */
    if ( bp_is_active( 'groups' ) ) :
     
    class Group_Extension_Example_1 extends BP_Group_Extension {
        /**
         * Your __construct() method will contain configuration options for 
         * your extension, and will pass them to parent::init()
         */
        function __construct() {
            $args = array(
                'slug' => 'group-extension-example-1',
                'name' => 'Group Extension Example 1',
            );
            parent::init( $args );
        }
     
        /**
         * display() contains the markup that will be displayed on the main 
         * plugin tab
         */
        function display( $group_id = NULL ) {
            $group_id = bp_get_group_id();
            echo 'What a cool plugin!';
        }
     
        /**
         * settings_screen() is the catch-all method for displaying the content 
         * of the edit, create, and Dashboard admin panels
         */
        function settings_screen( $group_id = NULL ) {
            $setting = groups_get_groupmeta( $group_id, 'group_extension_example_1_setting' );
     
            ?>
            Save your plugin setting here: <input type="text" name="group_extension_example_1_setting" value="<?php echo esc_attr( $setting ) ?>" />
            <?php
        }
     
        /**
         * settings_sceren_save() contains the catch-all logic for saving 
         * settings from the edit, create, and Dashboard admin panels
         */
        function settings_screen_save( $group_id = NULL ) {
            $setting = '';
     
            if ( isset( $_POST['group_extension_example_1_setting'] ) ) {
                $setting = $_POST['group_extension_example_1_setting'];
            }
     
            groups_update_groupmeta( $group_id, 'group_extension_example_1_setting', $setting );
        }
    }
    bp_register_group_extension( 'Group_Extension_Example_1' );
     
    endif; // if ( bp_is_active( 'groups' ) )
    

    【讨论】:

      猜你喜欢
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多