Subject: COM_featuredCheck delete all featured flags except one

Posted on: 16/05/21 05:24am
By: Anonymous

PHP Formatted Code
function COM_featuredCheck()
{
    global $_TABLES;

    // Look for multiple featured frontpage articles. If more than one pick the newest.
    $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE featured = 1 AND draft_flag = 0 AND frontpage = 1 AND date <= NOW() ORDER BY date DESC LIMIT 2";
    $resultB = DB_query($sql);
    $numB = DB_numRows($resultB);
    if ($numB > 1) {
        $B = DB_fetchArray($resultB);
        // un-feature all other featured frontpage story
        $sql = "UPDATE {$_TABLES['stories']} SET featured = 0 WHERE featured = 1 AND draft_flag = 0 AND frontpage = 1 AND date <= NOW() AND sid <> '{$B['sid']}'";
        DB_query($sql);
}
I have multiple topics and each topic has one featured article. The code above allows one featured article and delete the other featured flags through all topics. Is this how it works?

Re: COM_featuredCheck delete all featured flags except one

Posted on: 16/05/21 10:37am
By: Laugh

Yes that is how it works.

We did have a feature request for what you are describing at one point:

https://github.com/Geeklog-Core/geeklog/issues/793

but it was closed.

I would think it should be easy to implement (by just changing that SQL) but from what I remember their was some sort of problem which would crop up. Unfortunately I cannot remember what it was and I didn't leave a comment about it.

If it is something you want add a feature request and if you do customize your site with it be sure to include your code in the feature request so we can add it in.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=97403