Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [FIXED/SOLVED] Problems with this Forum  (Read 1155 times)

edsil

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 97
[FIXED/SOLVED] Problems with this Forum
« on: August 24, 2007, 06:31:42 pm »

Hi again...

I'm very sorry, I dont know if this post must go here... but I had some problems with this forum today, I was trying to read the post about "changing order of pages" (I really need to verify this MOD and so to read this post) : http://snewscms.com/forum/index.php?topic=4532.0

And when I click on it, this open the post and then (1 second later) it deassappears and I go to:
http://snewscms.com/forum/.db(

Can anyone of you send me (if it exist) a link to this post in the other forum?!... it is a little "urgent" that I need to read this MOD

Thanks
« Last Edit: August 25, 2007, 03:05:44 am by Phil Martin (Philmoz) »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Problems with this Forum
« Reply #1 on: August 24, 2007, 06:37:16 pm »

Yes you're right.  :(
Quote
There is a better version here it gives more options.  Please look at that before installing this.

UPDATED June 22, 2007  -  This was updated to work with modified moveup/movedown cases in the processing() function.  These cases were changed to make the usable with other mods. Like my Links MOD  If you already use this and want to use the Links MOD as well, find the green text below (HINT: Changes occur in steps 2, 4 and 6

Same MOD as here for 1.5, works in 1.6 as well:

This will allow you to change the order that your PAGES are displayed.


This MOD requires a new field in your database AND snews.php

STEP 1
BACK IT UP!!

STEP 2 - New Language Variables (snews.php) UPDATED
Quote
$l['up'] = 'Up';
$l['down'] = 'Down';
$l['please_wait'] = 'Please wait while you are redirected';
STEP 3 - function pages() (snews.php)
find
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";
change to
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY pageorder";
STEP 4 - function admin_articles($contents) (snews.php)
change to: ADD the blue, REMOVE the red, UPDATED[/b]
Quote
function admin_articles($contents) {
   switch ($contents) {
      case 'article_view': $title = l('articles'); $subquery = "WHERE position = 1  ORDER BY date DESC"; break;
      case 'extra_view': $title = l('extra_contents'); $subquery = "WHERE SUBSTRING(position,1,1) = '2' ORDER BY date DESC"; break;
      case 'page_view': $title = l('pages'); $subquery = "WHERE position = 3 ORDER BY pageorder ASC"; $pageorder = 'YES'; break;
   }
   echo '
'.$title.'
';
   $query = "SELECT * FROM ".db('prefix')."articles $subquery ORDER BY date DESC";
   $result = mysql_query($query);
   if (!$result || !mysql_num_rows($result)) {echo '

'.l('article_not_exist').'
';}
   else {
      $i = 0;
        while ($r = mysql_fetch_array($result)) {
         $articleSEF = $contents != 'extra_view' ? $r['seftitle'].'/' : '';
         
         if ($pageorder == 'YES') {
            $up_down =  '&item=pages&id='.$r['id'].'">'.l('up').' | &item=pages&id='.$r['id'].'">'.l('down').' '.l('divider');
         }
         
         echo '

'.$up_down.' '.date(s('date_format'), strtotime($r['date'])).' '.$r['title'].' '.l('divider').' '.l('view').' ';
         echo  l('divider').' '.l('edit').' ';
          if ($r['published'] == 2) {echo  l('divider').' ['.l('status').' '.l('future_posting').']';}
         if ($r['published'] == 0) {echo  l('divider').' ['.l('status').' '.l('unpublished').']';}
         echo '
';
         $i++;
      }
      echo '
';
}}
STEP 5 - function processing($contents) under case 'admin_article'; (snews.php)
find
Quote
case(isset($_POST['add_article'])):
                  mysql_query("INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta')");
                  $pos = substr($position, 0, 1);
                  switch ($pos) {case 1: $link = 'articles/'; break; case 2: $link = 'extra_contents/'; break; case 3: $link = 'pages/'; break;}
                  break;
change to
Quote
case(isset($_POST['add_article'])):
                 
                  if ($position == 3) {
                     $order = get_order(DESC) +1;
                     $ins_order = ", pageorder";
                     $value_order = ", '$order'";
                  }
                 
                  mysql_query("INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta".$ins_order.") VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta'".$value_order.")");
                  $pos = substr($position, 0, 1);
                  switch ($pos) {case 1: $link = 'articles/'; break; case 2: $link = 'extra_contents/'; break; case 3: $link = 'pages/'; break;}
                  break;
STEP 6 - function processing($contents) AFTER case 'deletecomment'; (snews.php)
- add the following 2 NEW CASES UPDATED - THIS HAS BEEN CHANGED TO ACCOMMODATE OTHER MODS replace existing moveup/movedown cases with the following
Quote
case 'moveup';
            $id_a = $_GET['id'];
            $item = $_GET['item'];
            switch ($item) {
                case 'links': $order = 'linkorder'; $link = 'admin_links'; break;
            case 'pages': $order = 'pageorder'; $link = 'pages';  $item = 'articles'; break;
            }
            $ordernum = retrieve($order,$item,'id',$id_a);
            if ($ordernum > 1) {
            $ordernum_a = $ordernum-1;
                $id = retrieve('id',$item,$order,$ordernum_a);
                $query1 = "UPDATE ".db('prefix')."$item SET $order = '$ordernum' WHERE id = '$id'";
                $result1 = mysql_query($query1) or die (mysql_error()."
Couldn't execute query: $query1");
               
                $query2 = "UPDATE ".db('prefix')."$item SET $order = '$ordernum_a' WHERE id = '$id_a'";
                $result2 = mysql_query($query2) or die (mysql_error()."
Couldn't execute query: $query2");
               
            }
            echo notification(0,l('please_wait'));
            echo '';
        break;
        case 'movedown';
            $id_a = $_GET['id'];
            $item = $_GET['item'];
            switch ($item) {
                case 'links': $order = 'linkorder'; $link = 'admin_links'; break;
            case 'pages': $order = 'pageorder'; $link = 'pages';  $item = 'articles'; break;
            }
            $ordernum = retrieve($order,$item,'id',$id_a);
           
            $query = "SELECT $order FROM ".db('prefix')."$item ORDER BY $order DESC LIMIT 1 ";
                $result = mysql_query($query) or die (mysql_error()."
Couldn't execute query: $query");
                $row = mysql_fetch_array($result);
                $high_ordernum = $row[$order];
               
            if ($ordernum < $high_ordernum) {
           
                $ordernum_a = $ordernum+1;
                $id = retrieve('id',$item,$order,$ordernum_a);
               
                $query1 = "UPDATE ".db('prefix')."$item SET $order = '$ordernum' WHERE id = '$id'";
                $result1 = mysql_query($query1) or die (mysql_error()."
Couldn't execute query: $query1");
               
                $query2 = "UPDATE ".db('prefix')."$item SET $order = '$ordernum_a' WHERE id = '$id_a'";
                $result2 = mysql_query($query2) or die (mysql_error()."
Couldn't execute query: $query2");
               
            }
            echo notification(0,l('please_wait'));
            echo '';
        break;
STEP 7 - new function get_order (snews.php)
- no special location, I put mine after the cleancheckSEF() function
Quote
function get_order($var) {
   $ad = $var == ASC ? 'ASC' : 'DESC';
   $query = "SELECT pageorder FROM ".db('prefix')."articles WHERE position = 3 ORDER BY pageorder ".$ad." LIMIT 1";
   $result = mysql_query($query);
   $r = mysql_fetch_array($result);
   return $r['pageorder'];
}
STEP 8 - Database change:
- copy/paste the text below into a file named setpages.php and place it in your main sNews directory.  This will create the extra field need in the database and will populate the "pageorder" field for the existing articles that are Pages.
Quote
include('snews.php');

mysql_query("ALTER TABLE ".db('prefix')."articles ADD pageorder SMALLINT( 6 ) NOT NULL DEFAULT '0'");

$query = "SELECT id FROM ".db('prefix')."articles WHERE position = 3";
$result = mysql_query($query);
$num = mysql_num_rows($result);
$id_array = array();
while ($r = mysql_fetch_array($result)) {$id_array[] = $r['id'];}

$i=1;
foreach($id_array as $v){
   $query = "UPDATE ".db('prefix')."articles SET pageorder = '$i' WHERE id = '$v'";
   $result = mysql_query($query);
   echo $query.'
';   
   $i++;
}
echo "";
unlink('setpages.php');
?>
STEP 9 - Point your browser to the setpages.php file.
Quote
http://yoursnewsinstall.com/subdirectoryifneeded/setpages.php
This has been saved.
Hope it will help you.

edsil

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 97
Re: Problems with this Forum
« Reply #2 on: August 24, 2007, 06:45:55 pm »

Salut Sven et merci

but I just need to read all this post because I need is the great MOD by Saint Keyrocks about change order of ARTICLES and not pages...

So if someone have this post about change order of articles, will be great and apreciate!

Thanks
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: Problems with this Forum
« Reply #3 on: August 25, 2007, 12:29:32 am »

that post seems to have been fixed now.
Logged
Of all the things I have lost, it is my mind that I miss the most.

edsil

  • Jr. Member
  • **
  • Karma: 5
  • Posts: 97
Re: Problems with this Forum
« Reply #4 on: August 25, 2007, 12:34:13 am »

 ;D Great! thanks a lot!!!!  ;D
Logged