code/extensions/FAQRelatedArticlesExtension.php
public function getRelatedFAQs($limit = null)
    {
        $tags = $this->owner->Tags();

        if ($tags->count() == 0) {
            return null;
        }

        // find any FAQ that has one of the same tags
        $faqs = FAQ::get()
            ->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
            ->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
            ->exclude('ID', $this->owner->ID);

        // limit the faqs if applicable
        if ($limit && is_int($limit)) {
            $faqs = $faqs->limit($limit);
        }

        return $faqs;
    }
public function getRelatedFAQs($limit = null)
    {
        $tags = $this->owner->Tags();

        if ($tags->count() == 0) {
            return null;
        }

        // find any FAQ that has one of the same tags
        $faqs = FAQ::get()
            ->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
            ->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
            ->exclude('ID', $this->owner->ID);

        // limit the faqs if applicable
        if ($limit && is_int($limit)) {
            $faqs = $faqs->limit($limit);
        }

        return $faqs;
    }
public function getRelatedFAQs ( $ limit = null ) { $ tags = $ this -> owner -> Tags ( ) ; if ( $ tags -> count ( ) == 0 ) { return null ; } // find any FAQ that has one of the same tags $ faqs = FAQ :: get ( ) -> innerJoin ( 'FAQ_Tags' , '"FAQ"."ID" = "FAQ_Tags"."FAQID"' ) -> where ( sprintf ( '"FAQ_Tags"."TaxonomyTermID" IN (%s)' , implode ( ',' , $ tags -> column ( 'ID' ) ) ) ) -> exclude ( 'ID' , $ this -> owner -> ID ) ; // limit the faqs if applicable if ( $ limit && is_int ( $ limit ) ) { $ faqs = $ faqs -> limit ( $ limit ) ; } return $ faqs ; }
Helper to get all the FAQ articles that are tagged with the same
tags.

@return DataList|null
Helper to get all the FAQ articles that are tagged with the same tags .