tags:

views:

25

answers:

1

I am not realy a php programmer myself, so any help would be appreciated. I run a website on cms e107.

Now I have installed a menu plugin called "Recent news menu" This will display the latest news articles in the selected menu area on the site.

Now my problem is that it also displays news that is set to "Not display" (see picture)

alt text

Can anyone help how to get this not displayed?

Here is all the code:

<?php
global $sql2, $tp;
$caption = "Recent news";
$no_news = "No news items";
$eol_separator = "</td></tr>";
$sol_separator = "<tr><td style='width:0%;text-align:left;'>";
$qry = "SELECT news_id, news_title FROM #news WHERE news_render_type = 0 ORDER BY news_id DESC LIMIT 0,5";

if($sql2->db_Select_gen($qry))
{
 $n_text = "<table style='width:100%;'>";
 while ($row = $sql2->db_Fetch())
 {
  $title = $tp->toHTML($row['news_title']);
  $n_text .=$sol_separator ."<a href='".e_HTTP."news.php?item.".$row['news_id']."'>".$title."</a>".$eol_separator;
 }
 $n_text .= "</table>";
}
else
{
 $n_text = $no_news;
}
$ns->tablerender($caption, $n_text);
+1  A: 

Since the code of this plugin doesn't look very good in general, I guess you might not want to use this plugin and look for a better one... but in case you want to use this plugin you could adjust the db query so that the items, which are not ment to be displayed are not selected. Something like this:

$qry = "SELECT news_id, news_title 
        FROM #news 
        WHERE news_render_type = 0 
            AND display = 1
        ORDER BY news_id DESC 
        LIMIT 0,5";

Depending on how the display information is stored, you might need to make it AND display > 0.

tharkun
Thanks,It's works now with:$qry = "SELECT news_id, news_title FROM #news WHERE news_render_type = 0 AND news_class NOT IN (255, 254) ORDER BY news_id DESC LIMIT 0,5";
Justmac