0

基本上我想将 Kunena 论坛部分链接设置为像HERE这样的标签。在首页显示特定部分的原始代码如下所示:

<?php
/**
 * Kunena Component
 * @package Kunena.Template.Blue_Eagle
 * @subpackage Category
 *
 * @copyright (C) 2008 - 2013 Kunena Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link http://www.kunena.org
 **/
defined ( '_JEXEC' ) or die ();

$tabclass = array ("row1", "row2" );
$mmm=0;
foreach ( $this->sections as $section ) :
    $htmlClassBlockTable = !empty ( $section->class_sfx ) ? ' kblocktable' . $this->escape($section->class_sfx) : '';
    $htmlClassTitleCover = !empty ( $section->class_sfx ) ? ' ktitle-cover' . $this->escape($section->class_sfx) : '';
?>
<div class="kblock kcategories-<?php echo intval($section->id) ?>">
    <div class="kheader">

        <h2><span><?php echo $this->GetCategoryLink ( $section, $this->escape($section->name) ); ?></span></h2>
        <?php if (!empty($section->description)) : ?>
        <div class="ktitle-desc km hidden-phone">
            <?php echo KunenaHtmlParser::parseBBCode ( $section->description ); ?>
        </div>
        <?php endif; ?>
    </div>
    <div class="kcontainer" id="catid_<?php echo intval($section->id) ?>">

    <!-- Here Comes Categories Displayed  As Tab Content-->

<!-- Finish: Category Module Position -->   
</div>
</div>

<?php endforeach; ?>

所以我把第一部分从

<div class="kheader">

            <h2><span><?php echo $this->GetCategoryLink ( $section, $this->escape($section->name) ); ?></span></h2>
            <?php if (!empty($section->description)) : ?>
            <div class="ktitle-desc km hidden-phone">
                <?php echo KunenaHtmlParser::parseBBCode ( $section->description ); ?>
            </div>
            <?php endif; ?>
        </div

<div class="navbar">
  <div class="navbar-inner">
    <ul class="nav">
      <ul id="sections-tab" class="nav nav-pills visible-desktop">
        <li class="active">
          <a id="sect<?php echo intval($section->id) ?>" href="#sect<?php echo intval($section->id) ?>" data-toggle="tab">
          <span class="sectiontab<?php echo intval($section->id) ?>"><?php echo $this->GetCategoryLink ( $section, $this->escape($section->name) ); ?></span>
          </a>
        </li>
      </ul>
    </ul>
 </div>
</div>

但它仍然正常显示部分。我知道我需要在导航栏类之间移动foreach ( $this->sections 作为 $section )但是......老实说,我卡在这里是因为不太了解 PHP。因此,任何帮助都非常有用。

4

1 回答 1

0

好,我知道了。Foreach 就是答案。我所做的是:

<?php
foreach ( $this->sections as $section ) : $x++;
?>
  <?php if ($x == 1) { echo '<li class="active">'; } else {echo '<li>';} ?>
  <a id="sectab<?php echo intval($section->id) ?>" href="#sect<?php echo intval($section->id) ?>" data-toggle="tab">
    <?php echo $this->escape($section->name); ?>
  </a>
  </li>
<?php endforeach; ?>

当然,在foreach之前我添加了变量$x=0这对我有很大帮助。

于 2013-08-07T21:43:09.840 回答