当前位置: 首页>>代码示例>>PHP>>正文


PHP Articles::getArticles方法代码示例

本文整理汇总了PHP中Articles::getArticles方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::getArticles方法的具体用法?PHP Articles::getArticles怎么用?PHP Articles::getArticles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Articles的用法示例。


在下文中一共展示了Articles::getArticles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 function indexAction($id = null)
 {
     $p = Tools::getValue('page', 1);
     if (!empty($id)) {
         $sql = "select ID, Name, MetaKeywords, MetaRobots, Description from ArticleCategories where (ID = {$id}) and (IsDeleted = 0);";
         $category = GetMainConnection()->query($sql)->fetch();
         if (empty($category['ID'])) {
             return AddAlertMessage('danger', 'Категории статей не существует.', '/');
         }
         $CategoryName = $category['Name'];
         $sql = "SELECT count(*) as RecordCount " . "FROM Articles a " . "WHERE a.CategoryID = {$id} " . "AND a.isActive = 1 " . "AND a.IsDeleted = 0";
         $rec = GetMainConnection()->query($sql)->fetch();
         $total = ceil($rec['RecordCount'] / ARTICLES_PER_PAGE);
         $sql = "SELECT a.ID, a.CategoryID, a.Name, a.ShortDescription, a.count_likes, a.CountComments, MainImageExt " . "FROM Articles a " . "WHERE a.CategoryID = {$id} " . "AND a.isActive = 1 " . "AND a.IsDeleted = 0 " . "ORDER BY a.CreateDate DESC, a.ID DESC " . "LIMIT " . ($p > 0 ? $p - 1 : 0) * ARTICLES_PER_PAGE . ", " . ARTICLES_PER_PAGE;
         $articles = GetMainConnection()->query($sql)->fetchAll();
     } else {
         $category = null;
         $CategoryName = 'Все статьи';
         $article = new Articles($this->context);
         $total = ceil($article->getArticles($p, null, true) / ARTICLES_PER_PAGE);
         $articles = $article->getArticles($p);
     }
     $this->view->setVars(array('CategoryName' => $CategoryName, 'articles' => $articles, 'pagination' => array('total_pages' => $total, 'current' => $p)));
     $this->view->breadcrumbs = array(array('url' => '/category', 'title' => 'Все статьи'));
     if (isset($category)) {
         $this->view->breadcrumbs[] = array('url' => '/articles/c-' . $id, 'title' => $CategoryName);
         $this->view->meta = array('meta_title' => $CategoryName, 'meta_description' => $category['Description'], 'meta_keywords' => $category['MetaKeywords']);
     } else {
         $this->view->meta = array('meta_title' => $CategoryName, 'meta_description' => $CategoryName, 'meta_keywords' => $CategoryName);
     }
     $this->view->generate();
 }
开发者ID:AleksandrChukhray,项目名称:good_deals,代码行数:32,代码来源:CategoryController.php

示例2: getContent

 public function getContent()
 {
     //статическая часть контента
     echo '<div class="container">
 <!-- Example row of columns -->
 <div class="row">
     <div class="col-md-9">
     <div class="articles">';
     //динамическая часть
     //        $result = DB::query("SELECT id, title, description, date, img_src FROM  articles ORDER BY date DESC");
     //        $this->getMessageQueryErr($result, __FUNCTION__);
     $result = Articles::getArticles(0, 5);
     foreach ($result as $key => $value) {
         printf("<article class='media'>\n                        <h2 class='media-heading'>%s</h2>\n                        <p>%s</p>\n                        <div class='media-body'>\n                            <img class='img-responsive'  src='%s' >\n                            <p>%s </p>\n                            <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details &raquo;</a></p>\n                        </div>\n                   </article>", $value[title], $value[date], $value[img_src], $value[description], $value[id]);
     }
     echo "</div>";
     echo "<button class='btn btn-primary btn-lg next'>Показать еще</button>";
     /*while ($content = $result->fetch_object()) {
                 printf("<article class='media'>
                             <h2 class='media-heading'>%s</h2>
                             <p>%s</p>
     
                             <div class='media-body'>
                                 <img class='img-responsive'  src='%s' >
                                 <p>%s </p>
                                 <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details &raquo;</a></p>
                             </div>
                        </article>", $content->title,$content->date, $content->img_src, $content->description, $content->id);
             }*/
     //статическая часть
     echo "</div>";
 }
开发者ID:notnull-ua,项目名称:blog,代码行数:32,代码来源:main.class.php

示例3: indexAction

 function indexAction()
 {
     $p = Tools::getValue('page', 1);
     $q = Tools::getValue('q', '');
     $AuthorID = Tools::getValue('author', null);
     $articles = new Articles($this->context);
     if ($AuthorID != null) {
         $sql = "SELECT ID, Name FROM Authors WHERE ID = {$AuthorID};";
         $author = GetMainConnection()->query($sql)->fetch();
         if (empty($author['ID'])) {
             return AddAlertMessage('danger', 'Такого автора не существует.', '/');
         }
         $AuthorName = $author['Name'];
         $total = ceil($articles->getArticles($p, 'AuthorID = ' . $AuthorID, true) / ARTICLES_PER_PAGE);
         $articles = $total > 0 ? $articles->getArticles($p, 'AuthorID = ' . $AuthorID) : null;
     } else {
         $AuthorName = '';
         $AddWhere = empty($q) ? '' : '(Name LIKE "%' . $q . '%" OR Description LIKE "%' . $q . '%")';
         $total = ceil($articles->getArticles($p, $AddWhere, true) / ARTICLES_PER_PAGE);
         $articles = $total > 0 ? $articles->getArticles($p, $AddWhere) : null;
     }
     $this->view->setVars(array('q' => $q, 'AuthorName' => $AuthorName, 'articles' => $articles, 'pagination' => array('total_pages' => $total, 'current' => $p)));
     $this->view->breadcrumbs = array(array('url' => '/search', 'title' => 'Поиск'));
     $this->view->generate();
 }
开发者ID:AleksandrChukhray,项目名称:good_deals,代码行数:25,代码来源:SearchController.php

示例4: array

<?php

/**
 * Created by PhpStorm.
 * User: Vladislav
 * Date: 23.11.2015
 * Time: 20:05
 */
require_once "classes/articles.class.php";
require_once "classes/Comments.class.php";
try {
    $response = array();
    $start = $_GET[start];
    $step = $_GET[step];
    if (isset($_GET[id])) {
        $id_article = $_GET[id];
    }
    switch ($_GET['action']) {
        case 'get_next_articles':
            $response = Articles::getArticles($start, $step);
            break;
        case 'get_next_comments':
            $response = Comments::getComments($id_article, $start, $step);
            break;
        default:
            throw new Exception('Wrong action');
    }
    echo json_encode($response);
} catch (Exception $e) {
    die(json_encode(array('error' => $e->getMessage())));
}
开发者ID:notnull-ua,项目名称:blog,代码行数:31,代码来源:ajax.php


注:本文中的Articles::getArticles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。