从问答里另外一个那里抄来的,稍微改了一下,加了个数量限制,我是打算作图片站。。哈哈,,先试试,
在这里把修改记录都记录下来。。
app/article/main.php
if ($article_list)
{
foreach ($article_list AS $key => $val)
{
$article_ids[] = $val['id'];
$article_uids[$val['uid']] = $val['uid'];
}
$article_topics = $this->model('topic')->get_topics_by_item_ids($article_ids, 'article');
$article_users_info = $this->model('account')->get_user_info_by_uids($article_uids);
$article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min');//这里新增
foreach ($article_list AS $key => $val)
{
$article_list[$key]['user_info'] = $article_users_info[$val['uid']];
if ($val['has_attach'])//这里新增
{
$article_list[$key]['attachs'] = $article_attachs[$val['id']];
}
}
}
views/default/article/square.tpl.htm
<div class="content" id="detail_<?php echo $val['id']; ?>">
<div class="hide-content markitup-box">
<?php echo FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($val['message']))); ?>
</div>
<?php if ($val['attachs']) { ?>
<div class="aw-upload-img-list width-auto" style="margin-top:15px;">
<?php
$i=1;
foreach($val['attachs'] AS $attach) { ?>
<a href="<?php echo $attach['attachment']; ?>" target="_blank" data-fancybox-group="thumb" rel="lightbox">
<img class="img-thumbnail" style="margin-bottom:15px;" src="<?php echo $attach[thumb]; ?>" alt="<?php echo $attach['file_name']; ?>" />
</a>
<?php $i++;if($i>1)
break;} ?>
阅读全文
收起全文