How to show images in MostView Widget
From TomatoCMS Documentation
You want to get the image_crop field in the list of most viewed articles, you can:
- If you are using mysql adapter:
Open /application/modules/news/widgets/mostviewed/models/dao/mysql/Article.php and add the image_crop field to the list of select columns:
/application/modules/news/widgets/mostviewed/models/dao/mysql/Article.php
class News_Widgets_MostViewed_Models_Dao_Mysql_Article extends Tomato_Model_Dao implements News_Widgets_MostViewed_Models_Interface_Article { ... public function getMostViewedArticles($limit, $categoryId = null) { $sql = sprintf("SELECT a.article_id, a.category_id, a.title, a.slug, a.activate_date, a.num_views, a.image_crop, c.name AS category_name, c.slug AS category_slug ...", /** * @since 2.0.8 */ mysql_real_escape_string($this->_lang)); ... } }
- If you are using pdo_mysql adapter:
Open /application/modules/news/widgets/mostviewed/models/dao/pdo/mysql/Article.php, and add the image_crop field to the list of select columns:
/application/modules/news/widgets/mostviewed/models/dao/pdo/mysql/Article.php
class News_Widgets_MostViewed_Models_Dao_Pdo_Mysql_Article extends Tomato_Model_Dao implements News_Widgets_MostViewed_Models_Interface_Article { ... public function getMostViewedArticles($limit, $categoryId = null) { $select = $this->_conn ->select() ->from(array('a' => $this->_prefix . 'news_article'), array('article_id', 'category_id', 'title', 'slug', 'activate_date', 'num_views', 'image_crop')) ... } }
