9 posts by 2 authors in: Forums > CMS Builder
Last Post: June 2, 2017   (RSS)

Is there a way to exclude a specific category from the main list/news feed?

we're trying to avoid the doubling of headlines that appear on our homepage...

thanks in advance!

By osga - May 15, 2017 - edited: May 15, 2017

thank you for the response... how would we implement this on the page...?

page included...

Attachments:

index_newsfeed.html 2K

Osga, I believe the only change you'll need to make is to add the 'where' clause as shown here:

  // load records
  list($articlesRecords, $articlesMetaData) = getRecords(array(
    'tableName'   => 'articles',
    'where'       => ' category NOT LIKE "%YourCategoryName%" ',
    'limit'       => '9',
    'loadUploads' => '0',
    'orderBy'     =>  'date DESC',
  ));

You'll need to edit YourCategoryName to match the actual category to be excluded.

~ Deborah

generates this error

"MySQL Error: Unknown column 'category' in 'where clause'"

(new page for code attached....)

That code should work if your list of categories is in the same table.

If your list of categories is in a separate table (i.e. Get options from database), try using the record number instead of the label.

For example, if the record number for the external category to exclude is record number 4, then:

    'where'       => 'category NOT LIKE "4" ',

See if that works.

Hi Deborah... we finally got this work with a little playing around, Note the "CategoryNum" as opposed to the suggested "category" in the statement (make a mental note of that)...

now the question is: Do you know the syntax for excluding more than 1 category?

  'where'       => ' categoryNum NOT LIKE "9" ',

thanks for all ur help so far!

Osga, try this:

 'where' => ' categoryNum NOT LIKE "9" AND categoryNum NOT LIKE "5"',

~ Deborah

that worked like a charm Deborah, Thank You!