<!--这里是可以的-->
<{volist name="comment_collection" id="comment"}>
<div class="single-comment-container" style="border:1px solid grey;margin-top: 10px;">
<{if condition="$comment['reply_id'] eq null"}>
<p class="comment-headding">
<a href="<{$comment.visitor_url}>">
<{$comment.visitor_name}>
</a>
<span> <{$comment.comment_date}></span>
</p>
<div class="single-comment-body">
<p class="comment-content" style="text-indent:30px;">
<{$comment.comment_content}>
</p>
</div>
<{/if}>
</div>
<{/volist}>
<!-- 这里不晓得什么软他得到的不是数组,是个字符串
<{mytag:travelcomment comments='$comment_collection' text_indent='20'}>
-->//我的模板标签 部分代码
protected $tags = [
'travelcomment' => ['attr'=>'comments,text_indent','close'=>0],
];
public function tagTravelcomment($tag){
$html_comment ="";
$text_indent = $tag['text_indent'];
$comment_collection = $tag['comments'];
var_dump($comment_collection);
exit;
foreach($comment_collection as $comment){
$html_comment =<<<EOT
<div class="single-comment-container" style="border:1px solid grey;margin-top: 10px;">
<p class="comment-headding">
<input type="hidden" id="comment_id" value="$replace_comment_id">
<a href="$replace_url">
$replace_visitor_name
</a>
<span> $replace_date</span>
</p>
<div class="single-comment-body">
<p class="comment-content" style="text-indent:$replace_indentpx;">
$replace_content
</p>
EOT;结果打印出来是这个string(19) "$comment_collection"
最佳答案