diff --git a/src/bb-modules/News/Api/Admin.php b/src/bb-modules/News/Api/Admin.php index 9ebf72dae..312d0d05d 100644 --- a/src/bb-modules/News/Api/Admin.php +++ b/src/bb-modules/News/Api/Admin.php @@ -31,7 +31,7 @@ class Admin extends \Api_Abstract $pager = $this->di['pager']->getSimpleResultSet($sql, $params, $per_page); foreach ($pager['list'] as $key => $item) { $post = $this->di['db']->getExistingModelById('Post', $item['id'], 'Post not found'); - $pager['list'][$key] = $this->getService()->toApiArray($post); + $pager['list'][$key] = $this->getService()->toApiArray($post, 'admin'); } return $pager; diff --git a/src/bb-modules/News/Service.php b/src/bb-modules/News/Service.php index f1eed9a1a..87690dac9 100644 --- a/src/bb-modules/News/Service.php +++ b/src/bb-modules/News/Service.php @@ -37,8 +37,7 @@ class Service public function getSearchQuery($data) { - $sql='SELECT *, - SUBSTRING( content, 1, LOCATE( "", content ) -1 ) AS excerpt + $sql='SELECT * FROM post WHERE 1 '; @@ -64,32 +63,35 @@ class Service public function toApiArray($row, $role = 'guest', $deep = true) { - $admin = $this->di['db']->getRow('SELECT name, email FROM admin WHERE id=:id', array('id'=>$row->admin_id)); - + $admin = $this->di['db']->getRow('SELECT name, email FROM admin WHERE id=:id', array('id' => $row->admin_id)); + + $pos = strpos($row->content, ''); + $excerpt = ($pos) ? substr($row->content, 0, $pos) : null; + $data = array( - 'id' => $row->id, - 'title' => $row->title, - 'content' => $row->content, - 'slug' => $row->slug, - 'image' => $row->image, - 'section' => $row->section, - 'publish_at' => $row->publish_at, - 'published_at' => $row->published_at, - 'expires_at' => $row->expires_at, - 'created_at' => $row->created_at, - 'updated_at' => $row->updated_at, - 'author' => array( - 'name' => $admin['name'], - 'email' => $admin['email'], + 'id' => $row->id, + 'title' => $row->title, + 'content' => $row->content, + 'slug' => $row->slug, + 'image' => $row->image, + 'section' => $row->section, + 'publish_at' => $row->publish_at, + 'published_at' => $row->published_at, + 'expires_at' => $row->expires_at, + 'created_at' => $row->created_at, + 'updated_at' => $row->updated_at, + 'author' => array( + 'name' => $admin['name'], + 'email' => $admin['email'], ), - 'excerpt' => $row->excerpt, + 'excerpt' => $excerpt, //'tags' => array('foo', 'bar', 'bas'), //@todo ); - - if($role == 'admin') { + + if ($role == 'admin') { $data['status'] = $row->status; } - + return $data; } } \ No newline at end of file diff --git a/src/bb-modules/News/html_admin/mod_news_index.phtml b/src/bb-modules/News/html_admin/mod_news_index.phtml index b5191d544..aff48f6a6 100644 --- a/src/bb-modules/News/html_admin/mod_news_index.phtml +++ b/src/bb-modules/News/html_admin/mod_news_index.phtml @@ -21,7 +21,6 @@ - # {% trans 'Title' %} {% trans 'Active' %} {% trans 'Date' %} @@ -80,6 +79,8 @@
+

If the text is very long you can use <!--more--> tag. Inserting this tag within the post will create and excerpt of text (before the tag) to be displayed in posts list. Users will be able to see whole content when they click on "Read more" button.

+
diff --git a/src/bb-modules/News/html_admin/mod_news_post.phtml b/src/bb-modules/News/html_admin/mod_news_post.phtml index f867866eb..c35cb2755 100644 --- a/src/bb-modules/News/html_admin/mod_news_post.phtml +++ b/src/bb-modules/News/html_admin/mod_news_post.phtml @@ -19,6 +19,8 @@
+

If the text is very long you can use <!--more--> tag. Inserting this tag within the post will create and excerpt of text (before the tag) to be displayed in posts list. Users will be able to see whole content when they click on "Read more" button.

+
diff --git a/src/bb-modules/News/html_client/mod_news_post.phtml b/src/bb-modules/News/html_client/mod_news_post.phtml index 251a93fb5..fca2db60f 100644 --- a/src/bb-modules/News/html_client/mod_news_post.phtml +++ b/src/bb-modules/News/html_client/mod_news_post.phtml @@ -2,7 +2,7 @@ {% block meta_title %}{{post.title}}{% endblock %} {% block breadcrumb %} -
  • {% trans 'Blog' %}/
  • +
  • {% trans 'Blog' %}/
  • {{post.title}}
  • {% endblock %}