0

So I want to use a jQuery tab container in my view script. I have tested it so I know I already have everything working.

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

But this is the content that I want to put into the pane:

<?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; ?>

How can I get that if/foreach block into the content param of the addPane function?

khellang
  • 17,550
  • 6
  • 64
  • 84
Andrew
  • 227,796
  • 193
  • 515
  • 708

1 Answers1

2

Maybe what you want is ob_start(), ob_get_clean() pair.

<?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'); ?>
Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173