Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [FIX] Some redundant code... (sNews 1.5.30)  (Read 6451 times)

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[FIX] Some redundant code... (sNews 1.5.30)
« on: December 27, 2006, 05:00:26 PM »

Hi, I hope this is the right place for this - it's not a bug, more like a small optimization of the code...

Anyway, digging through the sNews code and modifying it for my website, I found there's some redundant code inside sitemap function.

At the very beginning of the function, variable $link is defined and there are two lines below where it should have been used but it wasn't. You'll find these lines if you search for:

Quote
echo l('divider').'
That's actually what $link variable holds, so you can just change this code into

Quote
echo $link.
;) not much, eh... but... why hold it to myself only?

Mika

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 9
  • Posts: 1408
    • http://www.ni5ni6.com/
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #1 on: December 27, 2006, 05:29:15 PM »

Thx Dom :)

These are missing titles and redundant code fixes:
Quote
function sitemap() {
   # title
   echo '

'.l('sitemap').'

';
   # dynamic pages (articles at the position 3) and hardcoded pages section
   echo '

'.l('pages').'

';
   $link = l('divider').' '.l('home').'
';
   # archive link
   echo $link.'archive/" title="'.l('archive').'">'.l('archive').'
';
   # pages links fetched from db
   $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = '1' ORDER BY date";
   $result = mysql_query($query);
   $home = s('home_sef');
   while ($r = mysql_fetch_array($result)) {
      if ($r['id'] != s('display_page')) {echo $link.$home.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'
';}
   }
   # contact link
   echo $link.'contact/" title="'.l('contact').'">'.l('contact').'
';
   # sitemap link
   echo $link.'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'
';
   # RSS link
   echo $link.'rss/" title="'.l('rss_feed').'">'.l('rss_feed').'

';
...
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #2 on: December 27, 2006, 06:06:14 PM »

I didn't notice the titles were missing, thanks for that!

But I think you forgot the second redundant code fix:
Quote
while ($r = mysql_fetch_array($result)) {
        if ($r['id'] != s('display_page')) {echo l('divider').' '.$r['title'].'
';}
This, if I'm not mistaken, should be:
Quote
while ($r = mysql_fetch_array($result)) {
        if ($r['id'] != s('display_page')) {echo $link.$home.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'
';}
Logged

Mika

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 9
  • Posts: 1408
    • http://www.ni5ni6.com/
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #3 on: December 28, 2006, 08:13:32 AM »

Ups  :D

(okay, it's fixed now)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #4 on: December 30, 2006, 12:05:19 PM »

should be moved to bugs forum?  :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #5 on: December 30, 2006, 09:14:03 PM »

Naah, it's not a bug - everything functions alright even without this tiny fix.

I just wanted to let the developers know so the next release contains less of the redundant code (if there's any other left?) as there's a lot of code in which one can easily miss these not -that-important things...

And in what extent this really helps... I don't know, all I know is that here less is better and faster, right? I hope it helps.
Logged

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[FIX] Some redundant code... (sNews 1.5.30)
« Reply #6 on: January 02, 2007, 12:24:38 AM »

Of course it helps! Your work is much appreciated.

I'm just one of the "Organisation Nazi's" who like to have topics in the right forums.  I bet I must annoy the heck out of the admin here  :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future
Pages: [1]