File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
components/com_content/src Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1616use Joomla \CMS \Language \Multilanguage ;
1717use Joomla \CMS \MVC \Factory \MVCFactoryInterface ;
1818use Joomla \CMS \MVC \Model \ListModel ;
19+ use Joomla \CMS \Pagination \Pagination ;
1920use Joomla \CMS \Table \Table ;
2021use Joomla \Component \Content \Site \Helper \QueryHelper ;
2122use Joomla \Utilities \ArrayHelper ;
@@ -233,6 +234,17 @@ public function getItems()
233234 $ limit = $ this ->getState ('list.limit ' );
234235
235236 if ($ this ->_articles === null && $ category = $ this ->getCategory ()) {
237+ /**
238+ * Special case for blog layout with limit 0 - don't load articles for performance reasons. We also need to
239+ * create an empty pagination object to avoid fatal errors in the view.
240+ */
241+ if ($ limit == 0 && $ this ->getState ('view.layout ' ) === 'blog ' ) {
242+ $ this ->_articles = [];
243+ $ this ->_pagination = new Pagination (0 , 0 , 0 );
244+
245+ return $ this ->_articles ;
246+ }
247+
236248 $ model = $ this ->bootComponent ('com_content ' )->getMVCFactory ()
237249 ->createModel ('Articles ' , 'Site ' , ['ignore_request ' => true ]);
238250 $ model ->setState ('params ' , Factory::getApplication ()->getParams ());
Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ class HtmlView extends CategoryView
7272 */
7373 public function display ($ tpl = null )
7474 {
75+ /**
76+ * Pass the current layout to the model so it can apply special handling for the
77+ * blog layout. In the blog layout, if the total number of articles (leading +
78+ * intro + links) is 0, we skip loading any articles to avoid the performance
79+ * cost of loading all records when the limit is 0.
80+ */
81+ $ this ->getModel ()->setState ('view.layout ' , $ this ->getLayout ());
82+
7583 $ this ->commonCategoryDisplay ();
7684
7785 // Flag indicates to not add limitstart=0 to URL
You can’t perform that action at this time.
0 commit comments