Jump to content

Manipulating the streams


Tom Irons

Recommended Posts

I'm trying to exclude a list of forums from showing up in streams, What I've found so far was to hook into \IPS\Content\Search\Mysql\Query and change the filterByContent method.

So far this is what I've got:

public function filterByContent( array $contentFilters, $type = TRUE )
    {
        parent::filterByContent( $contentFilters, $type );

        $params = [];
        if ( \IPS\Dispatcher::i()->controller == 'streams' )
        {
            $where = [];

            foreach ( $contentFilters as $filter )
            {
                $app = explode( '\\', $filter->itemClass )[1];

                if ( in_array( $app, ['blog', 'cms', 'downloads', 'forums', 'gallery'] ) )
                {                    
                    $where[] = \IPS\Db::i()->in( 'index_container_id', \IPS\Settings::i()->ExcludeFromStreams_{$app}, TRUE );
                }
            }

            $this->where[] = array_merge( array( $type ? ( '( ' . implode( ' OR ', $where ) . ' )' ) : ( '!( ' . implode( ' OR ', $where ) . ' )' ) ), $params );
        }

        return $this;
    }

How would I exclude the class and the container id in the same statement?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...