Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: [MOD]Admin - Article categorisation  (Read 16580 times)

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
[MOD]Admin - Article categorisation
« on: May 17, 2007, 03:51:03 AM »

version 2.01 (for snews 1.6)
28 May 2007 -- see end of this post for any updates.

This MOD replaces the current article/page/extra content  view in the admin, with ones that show all articles grouped by their categories.
That is, at a glance listing, for sites with lots of categories/articles.
Plus, there is also a set of quick links to make new page, article, extra content, or category that can be displayed or removed by setting a switch in the code.

This MOD also shows the article id next to the article name.

Place this style for the access links into your style.css. Alter to however you see fit.
Code: [Select]
.New_Admin_Links {font-size:85%;text-align:center;}Place the following into the language function near top of snews.php.
Code: [Select]
$l['uncategorised'] = 'Uncategorised';Now, comment out your current    // ARTICLES - ADMIN LIST  function.
( place /*  before the title, and a   */ after the last   }  )
Then make a little room under it, and copy/paste the following code below it.
(This code is the modified  admin list, plus a new function to provide the access links.)

Code: [Select]
// ARTICLES - ADMIN LIST - modified
function admin_articles($contents) {
$showAdminLinks = 0;
$home= l('home');
$xt=1;
$catNAMES[$xt-2] = $contents == 'extra_view' ? l('all') : l('uncategorised');
$catNAMES[0]= $home;
$query1 = "SELECT * FROM ".db('prefix')."categories  ORDER BY id ASC";
$result1 = mysql_query($query1);
while($ct = mysql_fetch_array($result1)){
$catNAMES[$ct['id']]= $ct['name'];
$catSEF[$ct['id']] = $ct['seftitle'];
$xt++;
}
switch ($contents) {
case 'article_view': $title = l('articles'); $subquery = "WHERE position = 1"; break;
case 'extra_view': $title = l('extra_contents'); $subquery = "WHERE SUBSTRING(position,1,1) = '2'"; break;
case 'page_view': $title = l('pages'); $subquery = "WHERE position = 3"; break;
}

echo new_admin_links($showAdminLinks)."\n";
foreach ($catNAMES as $catkey => $catvalue) {
$subsubQuery = "AND category = $catkey ";
$query = "SELECT * FROM ".db('prefix')."articles $subquery AND category = $catkey ORDER BY category,date DESC";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
if ((!$result || !mysql_num_rows($result)) && $numrows !==0) {echo '<p>'.l('article_not_exist').'</p>';}
else {
if ($numrows) {
/*validation fix*/ $catSEF[$catkey] = $catkey==0?l('home_sef'):$catSEF[$catkey];
echo '<fieldset>'."\n".'<legend><a onclick="toggle(\''.$catSEF[$catkey].$catkey.'\')" style="cursor:pointer;" title="'.$catvalue.' '.$title.'">'.$catvalue.' '.$title.'</a>'.'</legend> '."\n";
echo '<div id="'.$catSEF[$catkey].$catkey.'" style="display:none;">'."\n";$i=0;
   while ($r = mysql_fetch_array($result)){
$articleSEF = $contents != 'extra_view' ? $r['seftitle'].'/' : '';
echo '<p><strong>'.$r['id'].' - '.$r['title'].'</strong> '.l('divider').' <a href="'.db('website').find_cat_sef($r['category']).'/'.$articleSEF.'">'.l('view').'</a> '."\n";
echo  l('divider').' <a href="'.db('website').'index.php?action=admin_article&id='.$r['id'].'">'.l('edit').'</a> '.date(s('date_format'), strtotime($r['date']));
/*altered--hidden page mod */if ($r['display_auto'] == 0){echo l('divider').l('hidden_page').l('divider');}/* shows hidden in admin*/
     if ($r['published'] == 2) {echo  l('divider').' ['.l('status').' '.l('future_posting').']'."\n";}
if ($r['published'] == 0) {echo  l('divider').' ['.l('status').' '.l('unpublished').']'."\n";}
echo '</p>';
$i++;
}
echo '</div></fieldset>'."\n";
}}}}

// New Admin Links.
function new_admin_links($offon){
if ($offon == 1){
$divider = "-".l('divider')."-";
$new_links = '<fieldset class="New_Admin_Links"><span>';
$new_links .= $divider.'<a href="'.db('website').'article_new/" title="'.l('article_new').'">'.l('article_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'page_new/" title="'.l('page_new').'">'.l('page_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'extra_new/" title="'.l('extra_new').'">'.l('extra_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'admin_category/" title="'.l('add_category').'">'.l('add_category').'</a>'.$divider.'</span></fieldset>';
return $new_links;}
}
to alter the occurence of the links, that is, if do not want them showing on the page at all,
locate this line near top of function
Code: [Select]
$showAdminLinks = 1;then change the value of $showAdminLinks = 1; to $showAdminLinks = 0;

Updates
28-may-2007 - validation fails with 'Home" article div. New code line added. ($catSEF[$catkey] = $catkey==0?l('home_sef'):$catSEF[$catkey];)

17-may-2007 -- original posting
« Last Edit: August 21, 2007, 08:25:54 PM by Phil Martin »
Logged
Of all the things I have lost, it is my mind that I miss the most.

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
[MOD]Admin - Article categorisation
« Reply #1 on: May 17, 2007, 05:10:16 PM »

phil, you didn't mention that it's very valuable... so I'll do that now. It's very valuable. :D
Thanks!

tuxStyle

  • Newbie
  • *
  • Karma: 0
  • Posts: 15
[MOD]Admin - Article categorisation
« Reply #2 on: May 17, 2007, 07:15:09 PM »

Read here how to apply the patch on Widows:
http://www.solucija.com/forum/viewtopic.php?id=4541

Patch:
With admin links:
http://www.activestyle.ca/sNews-patch-mod/mod.AdminArticleCategorisation2.00-WithAdminLinks-sn1.6

Without admin links:
http://www.activestyle.ca/sNews-patch-mod/mod.AdminArticleCategorisation2.00-WithoutAdminLinks-sn1.6

You still have to add by hand to your CSS file:
Code: [Select]
.New_Admin_Links {font-size:85%;text-align:center;}Very, very valuable indeed :)
10x man.
Logged

bakercad

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 105
  • Posts: 1670
    • http://exit20.com
[MOD]Admin - Article categorisation
« Reply #3 on: May 17, 2007, 07:48:37 PM »

ya this is extremely valuable.....IMO, this should be included in the core.  Makes a TON of sense.
Logged

Vinoth

  • Newbie
  • *
  • Karma: 1
  • Posts: 34
[MOD]Admin - Article categorisation
« Reply #4 on: May 20, 2007, 10:44:37 PM »

Yes indeed and change this line to

/ ARTICLES - ADMIN LIST - modified

// ARTICLES - ADMIN LIST - modified

in your coding.

Thanx for the mod.
Logged

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
[MOD]Admin - Article categorisation
« Reply #5 on: May 21, 2007, 05:17:25 AM »

Quote from: Vinoth
Yes indeed and change this line to

/ ARTICLES - ADMIN LIST - modified

// ARTICLES - ADMIN LIST - modified

in your coding.

Thanx for the mod.
oops...
thx

Done.
Logged
Of all the things I have lost, it is my mind that I miss the most.

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
[MOD]Admin - Article categorisation
« Reply #6 on: May 28, 2007, 03:39:29 PM »

updated -- validation error repaired.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Elessar

  • Newbie
  • *
  • Karma: 1
  • Posts: 45
Re: [MOD]Admin - Article categorisation
« Reply #7 on: September 28, 2007, 05:15:09 PM »

Huh,
I have a little problem coz i'm actually using snews 1.6 MU and the '// ARTICLES - ADMIN LIST' is not the same as the normal snews.

So do you know what code I must use ?
« Last Edit: September 29, 2007, 10:28:02 PM by Elessar »
Logged
I'm a french guy, so if I made some mistakes in my post, just tell me. ;)

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
Re: [MOD]Admin - Article categorisation
« Reply #8 on: October 01, 2007, 01:01:13 PM »

um, no, and being 1500 km from my devmachine, I won't be able to help out for the next 4-5 weeks.

with a bit of luck, another will step in here and assist.
Logged
Of all the things I have lost, it is my mind that I miss the most.

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 955
Re: [MOD]Admin - Article categorisation
« Reply #9 on: October 01, 2007, 01:19:35 PM »

... and being 1500 km from my devmachine...
whow ... that's really good distance from devmachine  ;D
Logged

Rui Mendes

  • Development,Testing, Support
  • sNews Dude
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1063
  • sNews1.80 Reborn
    • Comunidade Portuguesa
Re: [MOD]Admin - Article categorisation
« Reply #10 on: October 01, 2007, 06:02:50 PM »

Hello Elessar, I think is working (I test in localhost).

This is part of code, see first post and replace only "function admin_articles"
Code: [Select]
// ARTICLES - ADMIN LIST
function admin_articles($contents) {
$showAdminLinks = 0;
$home= l('home');
$xt=1;
$catNAMES[$xt-2] = $contents == 'extra_view' ? l('all') : l('uncategorised');
$catNAMES[0]= $home;
$query1 = "SELECT * FROM ".db('prefix')."categories  ORDER BY id ASC";
$result1 = mysql_query($query1);
while($ct = mysql_fetch_array($result1)){
$catNAMES[$ct['id']]= $ct['name'];
$catSEF[$ct['id']] = $ct['seftitle'];
$xt++;
}
switch ($contents) {
case 'article_view': $title = l('articles'); $subquery = "WHERE position = 1"; break;
case 'extra_view': $title = l('extra_contents'); $subquery = "WHERE SUBSTRING(position,1,1) = '2'"; break;
case 'page_view': $title = l('pages'); $subquery = "WHERE position = 3"; break;
}
echo new_admin_links($showAdminLinks)."\n";
foreach ($catNAMES as $catkey => $catvalue) {
$subsubQuery = "AND category = $catkey ";
$query = "SELECT * FROM ".db('prefix')."articles $subquery AND category = $catkey ORDER BY category,date DESC";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
if ((!$result || !mysql_num_rows($result)) && $numrows !==0) {echo '<p>'.l('article_not_exist').'</p>';}
else {
if ($numrows) {
/*validation fix*/ $catSEF[$catkey] = $catkey==0?l('home_sef'):$catSEF[$catkey];
echo '<fieldset>'."\n".'<legend><a onclick="toggle(\''.$catSEF[$catkey].$catkey.'\')" style="cursor:pointer;" title="'.$catvalue.' '.$title.'">'.$catvalue.' '.$title.'</a>'.'</legend> '."\n";
echo '<div id="'.$catSEF[$catkey].$catkey.'" style="display:none;">'."\n";$i=0;
  while ($r = mysql_fetch_array($result)) {
## MULTI_USER
if ($r['allow_edit'] == 'YES' || $r['author_id'] == $_SESSION['id'] || get_identity($_SESSION['id'], 'level') < '3') {
## END MULTI_USER
$articleSEF = $contents != 'extra_view' ? $r['seftitle'].'/' : '';
echo '<p><strong>'.$r['id'].' - '.$r['title'].'</strong> '.l('divider').' <a href="'.db('website').find_cat_sef($r['category']).'/'.$articleSEF.'">'.l('view').'</a> '."\n";
echo  l('divider').' <a href="'.db('website').'index.php?action=admin_article&id='.$r['id'].'">'.l('edit').'</a> '.date(s('date_format'), strtotime($r['date']));
/*altered--hidden page mod */if ($r['display_auto'] == 0){echo l('divider').l('hidden_page').l('divider');}/* shows hidden in admin*/
    if ($r['published'] == 2) {echo  l('divider').' ['.l('status').' '.l('future_posting').']'."\n";}
if ($r['published'] == 0) {echo  l('divider').' ['.l('status').' '.l('unpublished').']'."\n";}
echo '</p>';
$i++;}
}
## MULTI_USER
}
## END MULTI_USER
$i++;
}
echo '</fieldset>';
}}

// New Admin Links.
function new_admin_links($offon){
if ($offon == 1){
$divider = "-".l('divider')."-";
$new_links = '<fieldset class="New_Admin_Links"><span>';
$new_links .= $divider.'<a href="'.db('website').'article_new/" title="'.l('article_new').'">'.l('article_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'page_new/" title="'.l('page_new').'">'.l('page_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'extra_new/" title="'.l('extra_new').'">'.l('extra_new').'</a>';
$new_links .= $divider.'<a href="'.db('website').'admin_category/" title="'.l('add_category').'">'.l('add_category').'</a>'.$divider.'</span></fieldset>';
return $new_links;}
}
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Elessar

  • Newbie
  • *
  • Karma: 1
  • Posts: 45
Re: [MOD]Admin - Article categorisation
« Reply #11 on: October 01, 2007, 09:44:17 PM »

Hi Rui Mendes,

Thanks for your job, I modify my code with yours and it looks like if it is working. So I will check later if there are bugs or not, and I tell you how is it going.
Thanks for that mod coz it very useful, coz when you've got a lot of articles it was awful before your mod.
I've just a question, what the meaning of the number before each article ?
« Last Edit: October 01, 2007, 09:54:45 PM by Elessar »
Logged
I'm a french guy, so if I made some mistakes in my post, just tell me. ;)

Rui Mendes

  • Development,Testing, Support
  • sNews Dude
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1063
  • sNews1.80 Reborn
    • Comunidade Portuguesa
Re: [MOD]Admin - Article categorisation
« Reply #12 on: October 01, 2007, 10:04:14 PM »

I'm glad to help you.

The number is a identifier to the article (is unique), if you want to hide find this code and remove red text
Quote
echo '<p><strong>'.$r['id'].' - '.$r['title'].'</strong> '.l('divider').' <a href="'.db('website').find_cat_sef($r['category']).'/'.$articleSEF.'">'.l('view').'</a> '."\n";

Logged
Need a Job on Europe. Linkdin - Facebook / Group

Elessar

  • Newbie
  • *
  • Karma: 1
  • Posts: 45
Re: [MOD]Admin - Article categorisation
« Reply #13 on: October 07, 2007, 11:27:57 PM »

ok thanks a lot.
Logged
I'm a french guy, so if I made some mistakes in my post, just tell me. ;)

goran

  • Newbie
  • *
  • Karma: 3
  • Posts: 19
Re: [MOD]Admin - Article categorisation
« Reply #14 on: February 21, 2008, 08:23:27 PM »

Thanx for great MOD Philmoz....

A karma for you  ;)
Logged
/* Imagination is more important than knowledge. */
Pages: [1] 2