Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在smarty文件中添加计数器并用作参考?_Php_Jquery_Smarty_Prestashop_Prestashop 1.6 - Fatal编程技术网

Php 如何在smarty文件中添加计数器并用作参考?

Php 如何在smarty文件中添加计数器并用作参考?,php,jquery,smarty,prestashop,prestashop-1.6,Php,Jquery,Smarty,Prestashop,Prestashop 1.6,我用php编写了一些其他项目的代码,如下所示 <div class="post-wrap"> $i = 0; while ( have_posts() ) $i++; if($i==1) { $class= 'active'; } else { $class= ''; } <div class="box '.$class.'"></div> endwhile; </div> public fun

我用php编写了一些其他项目的代码,如下所示

<div class="post-wrap">
  $i = 0;
  while ( have_posts() )
  $i++;
  if($i==1) {
    $class= 'active';
  }
  else {
    $class= '';
  }

 <div class="box '.$class.'"></div>
 endwhile;
 </div>
public function hookfooter($params) {
  $popup_styles = "SELECT * FROM "._DB_PREFIX_."database ORDER BY `id` DESC LIMIT 1";
  $popup_styles_settings = Db::getInstance()->ExecuteS($popup_styles);
  $this->context->smarty->assign('PopupStyles',$popup_styles_settings);
  return $this->display(__FILE__, 'views/templates/front/footer-display.tpl');
 }
 {foreach from=$sliderValues item=row}
  <div class="box">name</div>
  <div class="box">name2</div>
  <div class="box">name3</div>
 {/foreach}
在这里,我获取了数据,并将值分配给smarty

在smarty里面,我的代码是这样的

<div class="post-wrap">
  $i = 0;
  while ( have_posts() )
  $i++;
  if($i==1) {
    $class= 'active';
  }
  else {
    $class= '';
  }

 <div class="box '.$class.'"></div>
 endwhile;
 </div>
public function hookfooter($params) {
  $popup_styles = "SELECT * FROM "._DB_PREFIX_."database ORDER BY `id` DESC LIMIT 1";
  $popup_styles_settings = Db::getInstance()->ExecuteS($popup_styles);
  $this->context->smarty->assign('PopupStyles',$popup_styles_settings);
  return $this->display(__FILE__, 'views/templates/front/footer-display.tpl');
 }
 {foreach from=$sliderValues item=row}
  <div class="box">name</div>
  <div class="box">name2</div>
  <div class="box">name3</div>
 {/foreach}
{foreach from=$sliderValues item=row}
名称
姓名2
名字3
{/foreach}
但在这里,我不知道如何使用while和make循环计数器,以便为jquery添加活动类。
那么有人能告诉我怎么做吗?任何帮助和建议都是非常值得的。谢谢

您的问题很让人困惑,但我想您只需要使用:


$sliderValues
的内容是什么?