0

そこで、ビュー スクリプトで jQuery タブ コンテナーを使用したいと考えています。私はそれをテストしたので、すでにすべてが機能していることがわかります。

<?php $this->tabContainer()->addPane('container-name', 'label', 'content goes here'); ?>
<?php echo $this->tabContainer('container-name'); ?>

しかし、これは私がペインに入れたいコンテンツです:

<?php if (count($this->resources->links) > 0): ?>
    <h3>Links</h3>
    <ul>
    <?php foreach ($this->resources->links as $link): ?>
        <li><?php echo $link->title; ?></li>
    <?php endforeach ?>
    </ul>
<?php endif; ?>

if/foreach ブロックを addPane 関数の content パラメータに入れるにはどうすればよいですか?

4

1 に答える 1

2

多分あなたが欲しいのはob_start()ob_get_clean()ペアです。

<?php
ob_start();
if (count($this->resources->links) > 0): ?>
    <h3>Links</h3>
    <ul>
    <?php foreach ($this->resources->links as $link): ?>
        <li><?php echo $link->title; ?></li>
    <?php endforeach ?>
    </ul>
<?php endif;
$things = ob_get_clean();
$this->tabContainer()->addPane('container-name', 'label', $things);
echo $this->tabContainer('container-name'); ?>
于 2009-12-14T07:56:43.733 に答える