public function actionView($slug)
 {
     $article = Article::get($slug);
     if (!$article) {
         throw new \yii\web\NotFoundHttpException('Article not found.');
     }
     return $this->render('view', ['article' => $article]);
 }
Example #2
0
 public function getCat()
 {
     return Article::cats()[$this->category_id];
 }
Example #3
0
 * 程序文件简介:
 * ==============================================
 */
use common\populac\modules\article\api\Article;
use yii\helpers\Html;
$this->title = $title;
$this->params['breadcrumbs'][] = $this->title;
function renderNode($node)
{
    if (!count($node->children)) {
        $html = '<li>' . Html::a($node->title, ['/ji_sheng_gong_zuo_dong_tai/cat', 'slug' => $node->slug]) . '</li>';
    } else {
        $html = '<li>' . $node->title . '</li>';
        $html .= '<ul>';
        foreach ($node->children as $child) {
            $html .= renderNode($child);
        }
        $html .= '</ul>';
    }
    return $html;
}
?>

<br/>
<ul>
    <?php 
foreach (Article::tree() as $node) {
    echo renderNode($node);
}
?>
</ul>
Example #4
0
<?php 
if (count($article->photos)) {
    ?>
    <div>
        <h4>Photos</h4>
        <?php 
    foreach ($article->photos as $photo) {
        ?>
            <?php 
        echo $photo->box(100, 100);
        ?>
        <?php 
    }
    ?>
        <?php 
    Article::plugin();
    ?>
    </div>
    <br/>
<?php 
}
?>
<p>
    <?php 
foreach ($article->tags as $tag) {
    ?>
        <a href="<?php 
    echo Url::to(['/ji_sheng_gong_zuo_dong_tai/cat', 'slug' => $article->cat->slug, 'tag' => $tag]);
    ?>
" class="label label-info"><?php 
    echo $tag;