How to show collection on frontend with pagination in Magento 2
Posted at: September 21, 2018 4:51 PM
Create routes.xml
Rsgitech\News\etc\frontend\routes.xml
Create Index.php Controller Action
Rsgitech\News\Controller\Index\Index.php
Create LinkNews.php Block
Rsgitech\News\Block\LinkNews.php
Get news link from system configuration
Create link.phtml Template File
Rsgitech\News\view\frontend\templates\link.phtml
Create default.xml Layout
Rsgitech\News\view\frontend\layout\default.xml
News link show in footer
Create ListNews.php Block
Rsgitech\News\Block\ListNews.php
Create listnews.phtml Template
Rsgitech\News\view\frontend\templates\listnews.phtml
Create news_index_index.xml Layout
Rsgitech\News\view\frontend\layout\news_index_index.xml
Create news_index_index.xml for display news listing
Create rsgitech.news.css CSS file
Rsgitech\News\view\frontend\web\css\rsgitech.news.css
Create css file for design
Then run below commands
Complete!!
Download source code: Download
This lesson also available on YouTube
More Posts - Magento 2 Module Development
- Create admin menu in magento 2
- Create system config in magento 2
- Create helper and get system config value Magento 2
- How to create table and install sample data in Magento 2
- Create collection in Magento 2
- Create admin grid listing in Magento 2
- How to add grid items in Magento 2
- How to edit grid items in Magento 2
- How to delete grid items in Magento 2
- How to show collection on frontend with pagination in Magento 2
- How to get single record from collection in Magento 2