dtnd30892 2019-06-17 07:31
浏览 98

将<details> </ details>添加到一个特定的Buddypress Xprofile字段(profile-loop.php)

If special xprofile field with id=10 has data then output following:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><details><?php bp_the_profile_field_value(); ?></details></td>

</tr>

for all other xprofile fields with data the output should be:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><?php bp_the_profile_field_value(); ?></td>

</tr>

How should I change the second while loop in the buddypress profile-loop.php?

<div class="bp-widget <?php bp_the_profile_group_slug(); ?>">

  <h2><?php bp_the_profile_group_name(); ?></h2>

  <table class="profile-fields">

    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>

      <?php if ( bp_field_has_data() ) : ?>

        <tr<?php bp_field_css_class(); ?>>

          <td class="label"><?php bp_the_profile_field_name(); ?></td>

          <td class="data"><?php bp_the_profile_field_value(); ?></td>

        </tr>

      <?php endif; ?>

      <?php

      do_action( 'bp_profile_field_item' ); ?>

    <?php endwhile; ?>

  </table>
</div>
  • 写回答

1条回答 默认 最新

  • douweng1904 2019-06-17 12:31
    关注

    I just solved it using bp_get_the_profile_field_id():

    <div class="bp-widget <?php bp_the_profile_group_slug(); ?>">
      <h2><?php bp_the_profile_group_name(); ?></h2>
        <table class="profile-fields">
          <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
          <?php if ( bp_get_the_profile_field_id() != '273' AND bp_field_has_data()) : ?>
          <tr<?php bp_field_css_class(); ?>>
            <td class="label"><?php bp_the_profile_field_name(); ?></td>
            <td class="data"><?php bp_the_profile_field_value(); ?></td>
          </tr>
          <?php else : ?>
          <tr<?php bp_field_css_class(); ?>>
            <td class="label"><?php bp_the_profile_field_name(); ?></td>
            <td class="data"><details><summary>Anzeigen</summary><?php bp_the_profile_field_value(); ?></details></td>
          </tr>
          <?php endif;?>
    ...
    
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突