0

I have one div which contain UL and LI. In this I want to generate dynamic Id of that LI. right now I given static id of this .

Now In this I want to generate my li's ID like given below. Now I'm bit confused how will I get this.

<li id= "nav-fragment-1">
<li id= "nav-fragment-2">
<li id= "nav-fragment-3">
<li id= "nav-fragment-4"> 


<div id="featured">
  <ul class="ui-tabs-nav">
<?php $i = 0; foreach($posts as $post): ?>
   <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1">
    <a href="<?php //echo $i++;) ?>"><span><?php echo $this->escape($post['title']) ?>
<?php if($leads): ?>
      <p><?php echo $this->maxText($post['content'], 50, '...', true) ?></p>
    <?php endif ?></span>
  <img class="post-image" src="<?php echo $this->postImage($post['image'], '50px', '50px') ?>" alt="" title="<?php echo $this->escape($post['title']) ?>"/></a>
 </li>
<?php endforeach ?>
</ul>
</div>

Edited by pritaeas: Changed to discussion thread.

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by wasim kazi
2

This should work:

<div id="featured">
  <ul class="ui-tabs-nav">
    <?php $i = 0; foreach($posts as $post): ?>
      <?php $i++; ?>
      <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $i; ?>">
        <a href="#">
          <span>
            <?php echo $this->escape($post['title']) ?>
            <?php if($leads): ?>
              <p><?php echo $this->maxText($post['content'], 50, '...', true) ?></p>
            <?php endif ?>
          </span>
          <img class="post-image" src="<?php echo $this->postImage($post['image'], '50px', '50px') ?>" alt="" title="<?php echo $this->escape($post['title']) ?>"/>
        </a>
      </li>
    <?php endforeach ?>
  </ul>
</div>

Edited by pritaeas

0

Thanks for your replay pritaeas.
I solved that problem. I add into my code like this and it's working.

 <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo ++$i; ?>">
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.