使用Mustache php访问父信息(周期为两个或更多)

发布于 2025-01-18 11:39:43 字数 5011 浏览 0 评论 0原文

首先,我的英语不好。 我正在使用小胡子php,并且已经在github中启动了主题 - https:// github。 com/bobthecow/usedache.php/essove/396

我有2个周期,这是代码:

$query_check = $this->db->query("SELECT * FROM ".$this->argos_db_prefix."tickets ORDER by id DESC LIMIT {$pagination['limit']['first']}, {$pagination['limit']['second']}");
$ticket_admin_form_array=[];//globalize
$ticket_admin_form_array2 = [];//globalize
$count = 0; //globalize
if ($query_check->rowCount() > 0) {
    $tickets_found = true; //we found results
    while ($row=$query_check->fetch(PDO::FETCH_ASSOC)) {
        $tid = $row['id'];
        $tq = $row['question'];
        $open = $row['open'];
        $category = $row['category'];
        $username = $row['username'];
        $date = date('d.m.y H:i:s', $row['date']);
        $text = $row['text'];
        
        $ticket_admin_form_array[]=[
            'ext_the_tickets_tid'=>$tid,
            'ext_the_tickets_cat'=>$category,
            'ext_the_tickets_tq'=>$tq, //question
            'ext_the_tickets_open_s'=>$open,
            'ext_the_tickets_username'=>$username,
            'ext_the_tickets_date'=>$date,
            'ext_the_tickets_text'=>$text,
        ];
        
        
        $get_all_msgs = $this->db->query("SELECT * FROM ".$this->argos_db_prefix."tickets_comments WHERE tid='$tid' order by id ASC");
        while ($row = $get_all_msgs->fetch(PDO::FETCH_ASSOC)) {
            $textt = $row['text'];
            $datet = date('d.m.y H:i:s', $row['date']);
            $authored = $row['authored'];
            $username = $row['username'];
            if ($authored == 1) {
                $authored = "($username):";
            } else {
                $authored = "<span style='color:red'>Administrator:</span>";
            }
            
            $count++; //we count the results and passing to array below

             
            $ticket_admin_form_array2[$count][$tid]=[
                'ext_the_tickets_authored'=>$authored,
                'ext_the_tickets_datec'=>$datet,
                'ext_the_tickets_textc'=>$textt,
            ];
        }

我的模板文件是:

{{#all_tickets_arr1}}
<div class="tickets_box t_{{ext_the_tickets_tid}}">[{{ext_the_tickets_cat}}] {{ext_the_tickets_tq}} | {{ext_the_tickets_lang_date}}: {{ext_the_tickets_date}} | {{ext_the_tickets_lang_status}}: 

</div>
<div class="t_container_style t_cont_{{ext_the_tickets_tid}}" style="display:none">
<div class="t_new_msg_body">({{ext_the_tickets_username}}): ({{ext_the_tickets_date}}): <br/>{{ext_the_tickets_text}}</div>


{{#all_tickets_arr2}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2}}


</div>
{{/all_tickets_arr1}}

我想为每张票证获得唯一的结果。现在,我在开始的每张门票中都会收到相同的评论。在底部,我有一个:

return $this->m->render(file_get_contents("ext/pok4/the_tickets/template/admin_form.html"), [
    'all_tickets_arr1'=> new ArrayIterator($ticket_admin_form_array),
    'all_tickets_arr2'=> new ArrayIterator($ticket_admin_form_array2),
    'ext_the_tickets_pagination'=>($tickets_found) ? $pagination['output'] : '',
    'ext_the_tickets_found_results'=>$tickets_found,
    'ext_the_tickets_lang_date'=>$this->lang['ext_the_tickets_date'],
    'ext_the_tickets_lang_status'=>$this->lang['ext_the_tickets_status'],
    'ext_the_tickets_lang_welcome'=>$this->lang['ext_the_tickets_welcome'],
    'ext_the_tickets_lang_open'=>$this->lang['ext_the_tickets_open'],
    'ext_the_tickets_lang_closed'=>$this->lang['ext_the_tickets_closed'],
    'ext_the_tickets_lang_send'=>$this->lang['ext_the_tickets_send'],
    'ext_the_tickets_lang_ticket_closed_adm'=>$this->lang['ext_the_tickets_ticket_closed'],
    'ext_the_tickets_lang_not_found'=>$this->lang['ext_the_tickets_no_tickets_for_now'],
]);

我使用两个阵列iTerrator将其传递给胡须PHP。

'all_tickets_arr1'=> new ArrayIterator($ticket_admin_form_array),
'all_tickets_arr2'=> new ArrayIterator($ticket_admin_form_array2),

我想使用ticket_id($ tid)和$计数模板中的all_tickets_arr2来获取每个门票的唯一结果(我的意思是唯一评论) 现在,正如我说的那样,每张票都有相同的评论。

问题在这里:

{{#all_tickets_arr2}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2}}

这一定是这样的东西:

{{#all_tickets_arr2.count.tid}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2.count.tid}}

我想...? :)

有人可以给我一个建议,该怎么做才能发表评论以显示每张门票的独特之处?

In first sorry for my bad english.
I'm using mustache PHP and i started topic in github already - https://github.com/bobthecow/mustache.php/issues/396

I have 2 while cycles, here is the code:

$query_check = $this->db->query("SELECT * FROM ".$this->argos_db_prefix."tickets ORDER by id DESC LIMIT {$pagination['limit']['first']}, {$pagination['limit']['second']}");
$ticket_admin_form_array=[];//globalize
$ticket_admin_form_array2 = [];//globalize
$count = 0; //globalize
if ($query_check->rowCount() > 0) {
    $tickets_found = true; //we found results
    while ($row=$query_check->fetch(PDO::FETCH_ASSOC)) {
        $tid = $row['id'];
        $tq = $row['question'];
        $open = $row['open'];
        $category = $row['category'];
        $username = $row['username'];
        $date = date('d.m.y H:i:s', $row['date']);
        $text = $row['text'];
        
        $ticket_admin_form_array[]=[
            'ext_the_tickets_tid'=>$tid,
            'ext_the_tickets_cat'=>$category,
            'ext_the_tickets_tq'=>$tq, //question
            'ext_the_tickets_open_s'=>$open,
            'ext_the_tickets_username'=>$username,
            'ext_the_tickets_date'=>$date,
            'ext_the_tickets_text'=>$text,
        ];
        
        
        $get_all_msgs = $this->db->query("SELECT * FROM ".$this->argos_db_prefix."tickets_comments WHERE tid='$tid' order by id ASC");
        while ($row = $get_all_msgs->fetch(PDO::FETCH_ASSOC)) {
            $textt = $row['text'];
            $datet = date('d.m.y H:i:s', $row['date']);
            $authored = $row['authored'];
            $username = $row['username'];
            if ($authored == 1) {
                $authored = "($username):";
            } else {
                $authored = "<span style='color:red'>Administrator:</span>";
            }
            
            $count++; //we count the results and passing to array below

             
            $ticket_admin_form_array2[$count][$tid]=[
                'ext_the_tickets_authored'=>$authored,
                'ext_the_tickets_datec'=>$datet,
                'ext_the_tickets_textc'=>$textt,
            ];
        }

My template file is:

{{#all_tickets_arr1}}
<div class="tickets_box t_{{ext_the_tickets_tid}}">[{{ext_the_tickets_cat}}] {{ext_the_tickets_tq}} | {{ext_the_tickets_lang_date}}: {{ext_the_tickets_date}} | {{ext_the_tickets_lang_status}}: 

</div>
<div class="t_container_style t_cont_{{ext_the_tickets_tid}}" style="display:none">
<div class="t_new_msg_body">({{ext_the_tickets_username}}): ({{ext_the_tickets_date}}): <br/>{{ext_the_tickets_text}}</div>


{{#all_tickets_arr2}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2}}


</div>
{{/all_tickets_arr1}}

i want to get unique results for every ticket. Now i get the same comments in every ticket which i started. In bottom i have this:

return $this->m->render(file_get_contents("ext/pok4/the_tickets/template/admin_form.html"), [
    'all_tickets_arr1'=> new ArrayIterator($ticket_admin_form_array),
    'all_tickets_arr2'=> new ArrayIterator($ticket_admin_form_array2),
    'ext_the_tickets_pagination'=>($tickets_found) ? $pagination['output'] : '',
    'ext_the_tickets_found_results'=>$tickets_found,
    'ext_the_tickets_lang_date'=>$this->lang['ext_the_tickets_date'],
    'ext_the_tickets_lang_status'=>$this->lang['ext_the_tickets_status'],
    'ext_the_tickets_lang_welcome'=>$this->lang['ext_the_tickets_welcome'],
    'ext_the_tickets_lang_open'=>$this->lang['ext_the_tickets_open'],
    'ext_the_tickets_lang_closed'=>$this->lang['ext_the_tickets_closed'],
    'ext_the_tickets_lang_send'=>$this->lang['ext_the_tickets_send'],
    'ext_the_tickets_lang_ticket_closed_adm'=>$this->lang['ext_the_tickets_ticket_closed'],
    'ext_the_tickets_lang_not_found'=>$this->lang['ext_the_tickets_no_tickets_for_now'],
]);

I use two array iterrators to passing it to mustache php.

'all_tickets_arr1'=> new ArrayIterator($ticket_admin_form_array),
'all_tickets_arr2'=> new ArrayIterator($ticket_admin_form_array2),

i want to to use ticket_id ($tid) and $count in templates for all_tickets_arr2 to get unique results for every ticket (unique comments i mean)
Now as i said every ticket have the same comments.

The problem is here:

{{#all_tickets_arr2}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2}}

this one must be something like this:

{{#all_tickets_arr2.count.tid}}
<div class="t_new_msg_body">{{&ext_the_tickets_authored}} ({{ext_the_tickets_datec}}): <br/>{{ext_the_tickets_textc}}</div>
{{/all_tickets_arr2.count.tid}}

i think... ? :)

can someone give me a advice what to do to make comments to show for every ticket uniquely ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文