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.

Pages: [1] 2

Author Topic: [Mini Mod] back link after Add/Edit articles  (Read 3200 times)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
[Mini Mod] back link after Add/Edit articles
« on: April 24, 2008, 05:37:56 PM »

hey all  :D

i edit articles while logged in as admin and browsing the articles,
the back link that pops with the notification take me to the admin articles page,
not to the article that i just edit.

now, after edit i click the back link and get the article  ;D
i think this can be added in more places in the script.

UPDATED: 12/5/08
New code below,
will clean up my posts asap, must run.  :P

awesome day
« Last Edit: May 12, 2008, 10:27:56 PM by mosh »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: back link after edit articles
« Reply #1 on: April 25, 2008, 05:20:44 AM »

Hey Mosh... good idea. Maybe you should publish this as a MOD in the Mods & Addons section. It's useful.  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [Mini Mod] back link after Add/Edit articles
« Reply #2 on: May 03, 2008, 06:40:24 PM »

Than you Mosh, is working great. Better for me to go back to edited article. K+
Logged

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [Mini Mod] back link after Add/Edit articles
« Reply #3 on: May 12, 2008, 02:06:38 PM »

 :D hey all
as fun noticed link dont work for extra edit,
i made a new version, in my test (snews16) all works,

install a bit different then befor,
if old ver of mod is in use, delete it please.


install
1) new code, copy( no php tags ):
Code: [Select]
<?php
////////////////////
/// added
$hs=l('home_sef');
$sefcatretrieve('seftitle''categories''id'$category);
$pos2id substr($position2);
$xpgsefretrieve('seftitle''articles''id'$pos2id);
//// added //
switch ($pos) {
//case 1: $link = 'articles'; break; 
case 1$link=(!empty($sefcat))? $sefcat.'/'.$seftitle $hs.'/'.$seftitle ; break; 
//case 2: $link = 'extra_contents'; break; 
case 2
if(!empty($sefcat)) {
$link= $sefcat;
} else if ($category===-1){
$link= $hs.'/'.$xpgsef;
} else {
$link= $hs;
}
break; 
//case 3: $link = 'pages'; break;
case 3$link $hs.'/'.$seftitle ; break;
}
///////////
?>


2) in snews.php find processing() function, find line 1726 ( on default pack )
comment it out.

Code: [Select]
<?php

switch (
$pos) {case 1$link 'articles'; break; case 2$link 'extra_contents'; break; case 3$link 'pages'; break;}

?>


3) paste the new code just under that line.
Code: [Select]
<?php

// switch ($pos) {case 1: $link = 'articles'; break; case 2: $link = 'extra_contents'; break; case 3: $link = 'pages'; break;}

                                        ## --> Enter New Code Here
/// Added NewCode
$hs=l('home_sef');
$sefcatretrieve('seftitle''categories''id'$category);
$pos2id substr($position2);
$xpgsefretrieve('seftitle''articles''id'$pos2id);
//// added //
switch ($pos) {
//case 1: $link = 'articles'; break; 
case 1$link=(!empty($sefcat))? $sefcat.'/'.$seftitle $hs.'/'.$seftitle ; break; 
//case 2: $link = 'extra_contents'; break; 
case 2
if(!empty($sefcat)) {
$link= $sefcat;
} else if ($category===-1){
$link= $hs.'/'.$xpgsef;
} else {
$link= $hs;
}
break; 
//case 3: $link = 'pages'; break;
case 3$link $hs.'/'.$seftitle ; break;
}
/////////// END NEW CODE //

switch(true) {
case(isset($_POST['add_article'])):
?>



awesome day 2 all
 :D
« Last Edit: May 12, 2008, 10:33:08 PM by mosh »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [Mini Mod] back link after Add/Edit articles
« Reply #4 on: May 12, 2008, 04:38:37 PM »

oh oh... another good Mod from Mo?
I'm gonna try it one day.
Greetings from Paris brother Mo.

EDIT: you now have 13 karma. I hope you don't mind. ;D

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [Mini Mod] back link after Add/Edit articles
« Reply #5 on: May 12, 2008, 05:19:42 PM »

Hey Brother Sven,
Greetings From Tel-aviv  :D

thank you for karma, it is welcome with open heart  :)

let me know if any bugs in mod  :P

awesome day 2 all

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [Mini Mod] back link after Add/Edit articles
« Reply #6 on: May 12, 2008, 05:37:14 PM »

@ Mosh... thanks for the updated mod above. You did not note where the new - first block of script is to be inserted. What function is it to be inserted into... and under what existing string(s)?  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [Mini Mod] back link after Add/Edit articles
« Reply #7 on: May 12, 2008, 06:24:51 PM »

@ keyrocks
hello :)

@ brother Mo
on http://cms-zen.com/ you have linked nomasis.com and I thnak you for that.
It's gonna be sold to another owner late june, and the most interesting content will be published on http://www.hiseo.fr
 ;)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [Mini Mod] back link after Add/Edit articles
« Reply #8 on: May 12, 2008, 07:02:44 PM »

@ keyrocks hey
i have updated the how to  :D
if the new code will not have bugs,
i will update the first post.

@Brother Sven hey
Congratz for good work with you site  8)
i will update the link on my site to http://www.hiseo.fr/.

 :P

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [Mini Mod] back link after Add/Edit articles
« Reply #9 on: May 12, 2008, 07:39:45 PM »

Thank you mosh, all 3 cases work as expected. For pages, extras and articles.
For extras, back link can be db('website')? K+
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [Mini Mod] back link after Add/Edit articles
« Reply #10 on: May 12, 2008, 09:06:00 PM »

@ keyrocks hey
i have updated the how to  :D
if the new code will not have bugs,
i will update the first post.

@ Mosh... where does the script in Step 1 in this post go?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [Mini Mod] back link after Add/Edit articles
« Reply #11 on: May 12, 2008, 09:51:13 PM »

Sir, step1 replace code in step2... step 3 is only to show where the code will look at final.

But first, you must roll back mod from first POST of mosh...
In his last tutorial post, that code from first step replace code from step2 in function processing. Locate code from step2 and replace with code from step1. Of course, in function processing().
« Last Edit: May 13, 2008, 12:16:34 AM by funlw65 »
Logged

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [Mini Mod] back link after Add/Edit articles
« Reply #12 on: May 12, 2008, 10:09:18 PM »

@ key  :D
im sorry i could not explain better,
--> here is a processing() function from a vanilla sNews16,
i added the mod and notes   ;D
it go in sNews.php file.
Code: [Select]
<?php
/*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/
# 7 changes noted, plus several minor syntax fixes.
function processing() {
# 1) 1.6.0 - "1," added before the lang def. in next string.
if ($_SESSION[db('website').'Logged_In'] != token()) {echo notification(1,l('error_not_logged_in'),'home');}
else {
$action clean(cleanXSS($_GET['action']));
  
$id clean(cleanXSS($_GET['id']));
  
$commentid $_POST['commentid'];
  
$approved $_POST['approved'] == 'on' 'True' '';
  
# 2) 1.6.0 - next string shortened.
  
$name clean(entity($_POST['name']));
  
$category $_POST['define_category'];
  
# 3) 1.6.0 - minor change next string.
  
$description clean(entity($_POST['description']));
  
# 4) 1.6.0 - next string shortened.
  
$title clean(entity($_POST['title']));
  
$seftitle $_POST['seftitle'];
$url cleanXSS($_POST['url']);
$comment str_replace("\'""&#38;#39;"$_POST['editedcomment']);
# Patch/fix applied - Oct.08.07
$text clean($_POST['text']);
# un-patched string
//$text = $_POST['text'];
  
$date date('Y-m-d H:i:s');
  
# 5) 1.6.0 - next 2 strings shortened.
  
$description_meta entity($_POST['description_meta']);
$keywords_meta entity($_POST['keywords_meta']);
  
$display_title $_POST['display_title'] == 'on' 'YES' 'NO';
$display_info $_POST['display_info'] == 'on' 'YES' 'NO';
  
$commentable $_POST['commentable'] == 'on' 'YES' 'NO';
$freez $_POST['freeze'] == 'on' 'YES' 'NO';
  
if ($freez == 'YES' && $commentable == 'YES') {$commentable 'FREEZ';}
$position $_POST['position'];
if ($position == 2) {$position $_POST['cat_dependant'] == 'on' 21 2;}
  
$publish_article = ($_POST['publish_article'] == 'on' || $position 1) ? 0;
  
$publish_category $_POST['publish'] == 'on' 'YES' 'NO';
  
$fpost_enabled false;
    if(
$_POST['fposting'] == 'on') {
$fpost_enabled true;
$publish_article 2;
$date $_POST['fposting_year'].'-'.$_POST['fposting_month'].'-'.$_POST['fposting_day'].' '.$_POST['fposting_hour'].':'.$_POST['fposting_minute'].':00';
    }
    
$task clean(cleanXSS($_GET['task']));
switch ($task) {
case 'save_settings':
if (isset($_POST['save'])) {
$website_title $_POST['website_title'];
     $home_sef $_POST['home_sef'];
$website_description $_POST['website_description'];
$website_keywords $_POST['website_keywords'];
$website_email $_POST['website_email'];
     $contact_subject $_POST['contact_subject'];
$language $_POST['language'];
$charset $_POST['charset'];
$date_format $_POST['date_format'];
$article_limit $_POST['article_limit'];
$rss_limit $_POST['rss_limit'];
$display_page $_POST['display_page'];
$display_new_on_home $_POST['display_new_on_home'];
$display_pagination $_POST['display_pagination'];
$num_categories $_POST['num_categories'];
$approve_comments $_POST['approve_comments'];
$comments_order $_POST['comments_order'];
$comment_limit $_POST['comment_limit'];
$word_filter_enable $_POST['word_filter_enable'];
$word_filter_file $_POST['word_filter_file'];
$word_filter_change $_POST['word_filter_change'];
$ufield = array('website_title' => $website_title,'home_sef' => $home_sef,'website_description' => $website_description,'website_keywords' => $website_keywords,'website_email' => $website_email,'contact_subject' => $contact_subject,'language' => $language,'charset' => $charset,'date_format' => $date_format,'article_limit' => $article_limit,'rss_limit' => $rss_limit,'display_page' => $display_page,'comments_order' => $comments_order,'comment_limit' => $comment_limit,'word_filter_file' => $word_filter_file,'word_filter_change' => $word_filter_change,'display_new_on_home' => $display_new_on_home,'display_pagination' => $display_pagination,'num_categories' => $num_categories,'approve_comments' => $approve_comments,'word_filter_enable' => $word_filter_enable,);
/* # 6) 1.6.0 -  Five - mysql_query($query_begin."
 strings in 1.5.31 have now been incorporated in the $ufield array string above.
------------------------------------------------------------------------------------------ */
while (list($key$value) = each($ufield)) {
mysql_query("UPDATE ".db('prefix')."settings SET VALUE = '$value' WHERE name = '$key' LIMIT 1;");}
$query_begin "UPDATE ".db('prefix')."settings SET VALUE = ";
echo notification(0,'','settings');
}
break;
case 'changeup':
if (isset($_POST['submit_pass'])) {
$user checkUserPass($_POST['uname']);
$pass1 checkUserPass($_POST['pass1']);
$pass2 checkUserPass($_POST['pass2']);
# 7) 1.6.0 - $secret = checkUserPass($_POST['secret']); in 1.5.31 is replaced here with next 3 strings:
if ($user && $pass1 && $pass2 && $pass1 === $pass2) {
$uname md5($user);
$pass md5($pass2);
$query "UPDATE ".db('prefix')."settings SET VALUE=";
mysql_query($query."'$uname' WHERE name='username' LIMIT 1;");
mysql_query($query."'$pass' WHERE name='password' LIMIT 1;");
echo notification(0,'','administration');
        
}
else {echo notification(1,l('pass_mismatch'),'settings');}
}
break;
case 'admin_category':
switch(true) {
case(empty($name)): echo notification(1,l('err_TitleEmpty').l('errNote')); form_categories(); break;
case(empty($seftitle)): echo notification(1,l('err_SEFEmpty').l('errNote')); form_categories(); break;
case(check_if_unique('category_name'$name$id)): echo notification(1,l('err_TitleExists').l('errNote')); form_categories(); break;
case(check_if_unique('category_seftitle'$seftitle$id)): echo notification(1,l('err_SEFExists').l('errNote')); form_categories(); break;
case(cleancheckSEF($seftitle) == 'notok'): echo notification(1,l('err_SEFIllegal').l('errNote')); form_categories(); break;
default:
switch(true) {
case(isset($_POST['add_category'])):
mysql_query("INSERT INTO ".db('prefix')."categories(name, seftitle, description, published) VALUES('$name', '$seftitle', '$description', '$publish_category')");
break;
case(isset($_POST['edit_category'])):
mysql_query("UPDATE ".db('prefix')."categories SET name = '$name', seftitle = '$seftitle', description = '$description', published = '$publish_category' WHERE id = $id LIMIT 1;");
break;
case(isset($_POST['delete_category'])):
mysql_query("DELETE FROM ".db('prefix')."categories WHERE id = $id LIMIT 1;");
break;
}
echo notification(0,'','categories');
}
break;
case 'order_category':
if (isset($_POST['order_category'])) {
$counter $_POST['counter'];
for($i 0$i $counter$i++) {
$category_order $_POST['catorder'][$i];
$counter_id $_POST['counter_id'][$i];
if (empty($category_order) || !is_numeric($category_order)) {$category_order 0;}
mysql_query("UPDATE ".db('prefix')."categories SET catorder = '$category_order' WHERE id = '$counter_id' LIMIT 1;");
}
echo notification(0,'','categories');
}
break;
case 'admin_article':
if (substr($position01) == 2) {
$category $_POST['define_category'];
$page $_POST['define_page'];
if ($category != -1) {$position '21'.$category;}
else if ($page != 0) {$position '22'.$page$category = -1;}
}
$_SESSION['temp']['title'] = $title$_SESSION['temp']['seftitle'] = $seftitle$_SESSION['temp']['text'] = $text;
switch(true) {
case(empty($title)): echo notification(1,l('err_TitleEmpty').l('errNote')); form_articles(''); unset($_SESSION['temp']); break;
case(empty($seftitle)): echo notification(1,l('err_SEFEmpty').l('errNote')); $_SESSION['temp']['seftitle'] = $_SESSION['temp']['title']; form_articles(''); unset($_SESSION['temp']); break;
case(cleancheckSEF($seftitle) == 'notok'): echo notification(1,l('err_SEFIllegal').l('errNote')); form_articles(''); unset($_SESSION['temp']); break;
case(check_if_unique('article_title'$title$id)): echo notification(1,l('err_TitleExists').l('errNote')); form_articles(''); unset($_SESSION['temp']); break;
case(check_if_unique('article_seftitle'$seftitle$id)): echo notification(1,l('err_SEFExists').l('errNote')); form_articles(''); unset($_SESSION['temp']); break;
default:
$pos substr($position01);
////////////////////////////////////////////////////
// MOD BACK LINK AFTER EDIT, 1 Line commemted out //
// switch ($pos) {case 1: $link = 'articles'; break; case 2: $link = 'extra_contents'; break; case 3: $link = 'pages'; break;}
///////////////////////////////////////////////////
$hs=l('home_sef');
$sefcatretrieve('seftitle''categories''id'$category);
$pos2id substr($position2);
$xpgsefretrieve('seftitle''articles''id'$pos2id);
switch ($pos) {
case 1$link=(!empty($sefcat))? $sefcat.'/'.$seftitle $hs.'/'.$seftitle ; break; 
case 2
if(!empty($sefcat)) {
$link= $sefcat;
} else if ($category===-1){
$link= $hs.'/'.$xpgsef;
} else {
$link= $hs;
}
break; 
case 3$link $hs.'/'.$seftitle ; break;
}
///// MOD BACK LINK AFTER EDIT ENDS //
switch(true) {
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')");
break;
case(isset($_POST['edit_article'])):
if ($fpost_enabled == true) {$future " date = '$date',";}
mysql_query("UPDATE ".db('prefix')."articles SET title='$title', seftitle = '$seftitle', text = '$text',".$future." category = '$category', position = '$position', displaytitle = '$display_title', displayinfo = '$display_info', commentable = '$commentable', published = '$publish_article', description_meta = '$description_meta', keywords_meta = '$keywords_meta' WHERE id = '$id' LIMIT 1;");
break;
case(isset($_POST['delete_article'])):
mysql_query("DELETE FROM ".db('prefix')."articles WHERE id = $id LIMIT 1;");
mysql_query("DELETE FROM ".db('prefix')."comments WHERE articleid = $id LIMIT 1;");
break;
}
echo notification(0,'',$link); unset($_SESSION['temp']);
}
break;
case 'editcomment':
if (isset($_POST['submit_text'])) {
mysql_query("UPDATE ".db('prefix')."comments SET name = '$name', url = '$url', comment = '$comment', approved = '$approved' WHERE id = '$commentid' LIMIT 1;");
}
else if (isset($_POST['delete_text'])) {
mysql_query("DELETE FROM ".db('prefix')."comments WHERE id = $commentid LIMIT 1;");
}
$articleid retrieve('articleid''comments''id'$commentid);
$link find_cat_sef($categoryid).'/'.retrieve('seftitle''articles''id'$articleid);
echo notification(0,'',$link);
break;
case 'deletecomment':
      
$commentid $_GET['commentid'];
    
$articleid $_GET['articleid'];
       
mysql_query("DELETE FROM ".db('prefix')."comments WHERE id = $commentid LIMIT 1;");
$link find_cat_sef($categoryid).'/'.retrieve('seftitle''articles''id'$articleid);
echo notification(0,''$link);
break;
}
}}
?>


@ fun hey  :D
thank you,
as for extras, back link can be db('website')?
it depands, extra can be display:
on All,
on home,
on category,
on page  :P

i wanted to view any content i edit after i edit it hehe, so the script do it.   ;D
« Last Edit: May 12, 2008, 10:21:33 PM by mosh »
Logged

adminphp

  • Full Member
  • ***
  • Karma: 4
  • Posts: 150
  • you must be a great snewser .
Re: [Mini Mod] back link after Add/Edit articles
« Reply #13 on: September 26, 2011, 01:18:49 PM »

hey, i was looking in mods in this forum, and i found this one (back link after edit articles) but there is a problem  in instalation of this mod.
so the question is /   where i should put the code of the first step..
everyday i face  problems when i create new article and i make a mistake in title or url  that makes me to start from the beginning.

please could any member here, explain to us how to install it in details as you do in all time..

thanks
« Last Edit: September 26, 2011, 01:20:22 PM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [Mini Mod] back link after Add/Edit articles
« Reply #14 on: September 27, 2011, 07:24:51 AM »

hi adminphp,
on snews.php, find function  --- > processing(),
then find  --- > case 'admin_article':
few lines below, find --- >         default:
                               $pos = substr($position, 0, 1);
comment out the line below:
switch ($pos) {case 1: $link = 'articles'; break; case 2: $link = 'extra_contents'; break; case 3: $link = 'pages'; break;}

add the mod code below that.


you can see how it is installed on this example:
http://snewscms.com/forum/index.php?topic=7301.msg52426#msg52426


hope that help.

awesome day to all
 8)
Pages: [1] 2