findPublishedWithTeaserByPid() public static method

Find all published articles with teaser by their parent ID
public static findPublishedWithTeaserByPid ( integer $intPid, array $arrOptions = [] ) : Collection | ArticleModel[] | ArticleModel | null
$intPid integer The page ID
$arrOptions array An optional options array
return Contao\Model\Collection | ArticleModel[] | ArticleModel | null A collection of models or null if there are no articles in the given column
Esempio n. 1
0
 /**
  * Get all searchable pages and return them as array
  *
  * @param integer $pid
  * @param string  $domain
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public static function findSearchablePages($pid = 0, $domain = '', $blnIsSitemap = false)
 {
     $objPages = \PageModel::findPublishedByPid($pid, array('ignoreFePreview' => true));
     if ($objPages === null) {
         return array();
     }
     $arrPages = array();
     // Recursively walk through all subpages
     foreach ($objPages as $objPage) {
         if ($objPage->type == 'regular') {
             // Searchable and not protected
             if ((!$objPage->noSearch || $blnIsSitemap) && (!$objPage->protected || \Config::get('indexProtected') && (!$blnIsSitemap || $objPage->sitemap == 'map_always')) && (!$blnIsSitemap || $objPage->sitemap != 'map_never')) {
                 $arrPages[] = $objPage->getAbsoluteUrl();
                 // Get articles with teaser
                 if (($objArticles = \ArticleModel::findPublishedWithTeaserByPid($objPage->id, array('ignoreFePreview' => true))) !== null) {
                     foreach ($objArticles as $objArticle) {
                         $arrPages[] = $objPage->getAbsoluteUrl('/articles/' . ($objArticle->alias ?: $objArticle->id));
                     }
                 }
             }
         }
         // Get subpages
         if ((!$objPage->protected || \Config::get('indexProtected')) && ($arrSubpages = static::findSearchablePages($objPage->id, $domain, $blnIsSitemap))) {
             $arrPages = array_merge($arrPages, $arrSubpages);
         }
     }
     return $arrPages;
 }