コード例 #1
0
ファイル: functions.php プロジェクト: szcrystal/woau_backup
function listCategory($blog_id)
{
    if ($cates = App\Blog::find($blog_id)->cateRelation) {
        $ret = '<ul style="list-style:none;" class="clearfix">' . "\n";
        foreach ($cates as $cate) {
            $cateObj = App\Cate::find($cate->cate_id);
            $ret .= '<li class="pull-left">';
            $ret .= '<a href="' . getUrl("blog/category/" . $cateObj->slug) . '">' . $cateObj->c_name . '</a>';
            $ret .= '</li>' . "\n";
        }
        $ret .= '</ul>' . "\n";
        return $ret;
    } else {
        return '';
    }
}
コード例 #2
0
@if( ! $blogObj->cateRelation ->isEmpty())
    <h5><span class="octicon octicon-tag"></span>カテゴリー</h5>
    <ul class="clearfix">   
    <?php 
$cates = $blogObj->cateRelation;
$format = "<li><a href=\"%s\">%s</a>%s</li>\n";
foreach ($cates as $cate) {
    $cateObj = App\Cate::find($cate->cate_id);
    printf($format, getUrl('blog/category/' . $cateObj->slug), $cateObj->c_name, $cates->last() == $cate ? "" : "、");
}
?>

    </ul>
@endif