Hello

September 07, 2010, 05:15:44 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
What sNews Is: - sNews is a simple, basic, customizable CMS tool suitable for developers with beginner-to-advanced PHP skills. It is also useful to have a good working knowledge of how to work with, set up and manage MySQL databases. sNews is not - geared towards the end-user who knows little or nothing about building and developing PHP-MySQL based websites.
News: Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: [MOD] Multiple Areas for Categories  (Read 6901 times)
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« on: May 17, 2007, 05:18:25 PM »

My first mod for sNews 1.6.
New modification "limitation your articles from each category"  September, 1



Multiple Areas(zones) for Categories (MA 1.0) - cat1, cat 2, cat 3 and cat 4 - means I have 4 areas for categories
Quote
cat1 - put in new category Position Area=0 (see right image)
cat2 - put in new category Position Area=1
cat3 - put in new category Position Area=2
cat4 - put in new category Position Area=3
See how to use in your index.php in examples

If you want more then one areas for put your categories, this is works fine.
Example :
Top category, Left category, Right Category

You can :
- Show / Hide count (articles) in category
- Show / Hide category in sitemap

Very simple, just few code
In SQL database:
Code:
alter table categories add catnumber int(6) default '0';
alter table categories add showcount varchar(4) NOT NULL default 'YES';
alter table categories add showsitemap varchar(4) NOT NULL default 'YES';
Add red lines in categories function: Purple new modification

Quote
// DISPLAY CATEGORIES
function categories($num, $showhome, $showcnt, $start, $size) {
   if ($num=='') $num=0;
   if ($showhome==''|| $showhome!='false')$showhome='true'; else $showhome='false';
   if ($showcnt=='' || $showcnt!='false')$showcnt='true'; else $showcnt='false';

   $categorySEF = get_id('category');
   $class = $category_title == $categorySEF ? ' class="current"' : '';
   if ($num==0 || $showhome=='true') echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
   $query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES' AND catnumber='$num' ORDER BY catorder ASC";
   if (!empty($start) && !empty($size)) $query .=" LIMIT $start, $size";
   $result = mysql_query($query); $num_cat = mysql_num_rows($result);
   if ($num_cat==0 && $showhome!='true'){echo l('no_articles');} else
   while ($r = mysql_fetch_array($result)) {
      $calc_num_query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND category = $r[id] AND published = 1";
      $cm_result = mysql_query($calc_num_query);
      $num_rows = mysql_num_rows($cm_result);
      $category_title = $r['seftitle'];
      $class = $category_title == $categorySEF ? ' class="current"' : '';
      echo '<li><a'.$class.' href="'.db('website').$category_title.'/" title="'.$r['description'].'">'.$r['name'];
//echo (s('num_categories') == 'on' ? ' ('.$num_rows.')' : '').'</a></li>';
      if ($showcnt=='true' && $r['showcount']=='YES') echo ' ('.$num_rows.')'; echo '</a></li>';
}}
Add red code in sitemap
Quote
echo '</p>';
   $cat_query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES' AND showsitemap = 'YES' ORDER BY catorder";
   $cat_result = mysql_query($cat_query);
   while ($c = mysql_fetch_array($cat_result)) {

Find blue text and add line red

Quote
// CATEGORIES FORM
function form_categories() {
...
      $frm_description = $r['description'];
      $frm_publish = $r['published'] == 'YES' ? 'ok' : '';

      $frm_numcat = $r['catnumber'];
      $frm_showsitemap = $r['showsitemap'] == 'YES' ? 'ok' : '';
      $frm_showcount = $r['showcount'] == 'YES' ? 'ok' : '';

      $frm_task = 'edit_category';
...
      $frm_description = '';
      $frm_publish = 'ok';

      $frm_numcat = 0;
      $frm_showsitemap = 'ok';
      $frm_showcount = 'ok';

      $frm_task = 'add_category';
...
   echo html_input('text', 'seftitle', 's', $frm_sef_title, l('sef_title_cat'), '', '', '', '', '', '', '', '', '', '');
   echo html_input('text', 'description', 'desc', $frm_description, l('description'), '', '', '', '', '', '', '', '', '', '');

   echo html_input('text', 'cat_num', 'catnum', $frm_numcat, l('cat_num'), '', '', '', '', '', '', '', '', '', '');
   echo html_input('checkbox', 'showcount', 'scnt', 'YES', l('show_count'), '', '', '', '', $frm_showcount, '', '', '', '', '');
   echo html_input('checkbox', 'showsitemap', 'ssm', 'YES', l('show_sitemap'), '', '', '', '', $frm_showsitemap, '', '', '', '', '');

   echo html_input('checkbox', 'publish', 'pub', 'YES', l('publish_category'), '', '', '', '', $frm_publish, '', '', '', '', '');

...
In function processing()
found
Code:
  $publish_article = ($_POST['publish_article'] == 'on' || $position > 1) ? 1 : 0;
   $publish_category = $_POST['publish'] == 'on' ? 'YES' : 'NO';
append this 3 lines
Code:
$catnumber = $_POST['cat_num'];
$showsitemap = $_POST['showsitemap'] == 'on' ? 'YES' : 'NO';
$showcount = $_POST['showcount'] == 'on' ? 'YES' : 'NO';
found again
Code:
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'])):
Add red lines
Quote
default:
               switch(true) {
                  case(isset($_POST['add_category'])):
                  mysql_query("INSERT INTO ".db('prefix')."categories(name, seftitle, description, published, catnumber, showcount, showsitemap) VALUES('$name', '$seftitle', '$description', '$publish_category', '$catnumber', '$showcount', '$showsitemap')");
                  break;
                  case(isset($_POST['edit_category'])):
                  mysql_query("UPDATE ".db('prefix')."categories SET name = '$name', seftitle = '$seftitle', description = '$description', published = '$publish_category', catnumber ='$catnumber', showcount = '$showcount', showsitemap ='$showsitemap' WHERE id = $id LIMIT 1;");
                  break;
                  case(isset($_POST['delete_category'])):
                  mysql_query("DELETE FROM ".db('prefix')."categories WHERE id = $id LIMIT 1;");
                  break;
               }

Dont forget to add in language section
$l['cat_num'] = 'Category Area';
$l['show_count'] = 'Count articles on category';
$l['show_sitemap'] = 'Show in Sitemap';
$l['no_categories'] = 'No categories at the moment';


How can you use it ?
In your index.php or calling function

Sintax: <?php categories(Area, home, count, start, size); ?>
Area - category number
home - show(true) or hide (false)
count (articles) - show(true) or hide (false)
start - start article
size - how many articles you want to show

You can use (examples)
<?php categories(); ?> - this call categories Position=0, show home, and count articles
<?php categories(1); ?> - this call categories Position=1, show home and count articles
<?php categories(1,'false'); ?> - this call categories Position=1, dont show home and count categories
<?php categories(2,'false','false'); ?> - this call categories Position=2 hide home and not count categories
<?php categories(10,'false','false',1,3); ?> - this call categories Position=10 hide home and not count categories, show categories 1 to 3 from that area


Complicated ?
You can Download Here (don't forget to add purple text in categories function.)

Best reagards
Rui Mendes
« Last Edit: October 18, 2007, 09:48:23 PM by Keyrocks » Logged

Loretteville,Quebec@Canada.
tuxStyle
Newbie
*

Karma: 0
Posts: 16


« Reply #1 on: May 17, 2007, 08:23:06 PM »

Read here how to apply the patch on Windows:
http://snewscms.com/forum/index.php?topic=4541.0

Patch:
http://www.activestyle.ca/sNews-patch-mod/mod.MAC1.0-sn1.6

Change mysql tables:
Code:
alter table categories add catnumber int(6) default '0';    
alter table categories add showcount varchar(4) NOT NULL default 'YES';    
alter table categories add showsitemap varchar(4) NOT NULL default 'YES';
And read the manual Smiley
« Last Edit: October 06, 2007, 02:40:25 PM by Keyrocks » Logged
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #2 on: May 19, 2007, 08:18:12 PM »

Hello

To avoid confusion with Macos I rename MAC to MA (Multiple Areas for Categories), same file

Here some pictures of this MOD



I'll away for a few days. I'll visit NJ, NY - USA.

See you on 31 may 2007
« Last Edit: September 01, 2007, 03:44:03 PM by Rui Mendes » Logged

Loretteville,Quebec@Canada.
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #3 on: September 01, 2007, 03:11:07 PM »

To continue Pali ideia

New Modification for Multiple Areas for Categories. This new feature you can limit your articles from each area of category.

Best regards
Rui Mendes
Logged

Loretteville,Quebec@Canada.
Keyrocks
Doug
Administrator
ULTIMATE member
******

Karma: 419
Posts: 5568


Semantically Challenged


WWW
« Reply #4 on: October 06, 2007, 02:42:56 PM »

@ Rui... what is the status of this mod?
Are you working on a revised or improved release?
Is the current mod considered as running stable?
Logged

Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #5 on: October 07, 2007, 01:48:23 AM »

Hello @Key.

Yes this MOD is working and stable. This is a small MOD but very Powerful.
I don't know is somebody are using, for me is very, very usefull.

Is very useful for who wants more than 1 area/section for categories.

You can see it working in Portuguese Website. I use 3 areas as you can see in next image



« Last Edit: October 07, 2007, 01:53:50 AM by Rui Mendes » Logged

Loretteville,Quebec@Canada.
H.A.C
Jr. Member
**

Karma: 19
Posts: 86


i love snews community for its great members


WWW
« Reply #6 on: October 07, 2007, 03:44:10 AM »

Thank you so much. You MOD is really useful because I want a complex menu system other than a single menu.
Logged

I'm not available ....until the end of the year 2009!
----------------------------
The largest website powered by sNews is in its way to become the biggest!
My great personal website powered by sNews 1.6
http://www.chasoft.net
Come to see how it's great!
sibas
Full Member
***

Karma: 9
Posts: 193


WWW
« Reply #7 on: October 09, 2007, 10:57:40 AM »

Hi, can I have more than 4 areas?
This can work with MU?
Logged
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #8 on: October 09, 2007, 11:00:21 AM »

Yes sibas, no limit
 Grin

I integrate sNewsMU AM, so you can use it in sNewsMU
Logged

Loretteville,Quebec@Canada.
sibas
Full Member
***

Karma: 9
Posts: 193


WWW
« Reply #9 on: October 09, 2007, 11:42:31 AM »

This is so helpful Rui thank you a lot  Grin
Logged
funlw65
Hero Member
*****

Karma: 95
Posts: 799



WWW
« Reply #10 on: November 02, 2007, 05:13:34 PM »

Yes sibas, no limit
 Grin

I integrate sNewsMU AM, so you can use it in sNewsMU

Hi Rui,
You know what you have done here ?  Grin
If you can implement a system for access rights (on areas/categories created by admin) on MU version, we have a ... INTEGRATED FORUM !!!
Any user can create a topic/article in a area/category and the rest of us can reply/comment. What you think? Admin can create a separate page and categories for forum. No bridges anymore!!!
« Last Edit: November 02, 2007, 05:23:19 PM by funlw65 » Logged
funlw65
Hero Member
*****

Karma: 95
Posts: 799



WWW
« Reply #11 on: November 02, 2007, 05:18:09 PM »

Anyway, for me, single user version with this mod is great. I have a few hobbies and for everyone I need it a Area.
« Last Edit: November 02, 2007, 05:23:54 PM by funlw65 » Logged
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #12 on: November 02, 2007, 08:12:51 PM »

Hell funlw65 and thank you.

This power mod, can be used in subcategories (just new ideia must need devellop)
Logged

Loretteville,Quebec@Canada.
Keyrocks
Doug
Administrator
ULTIMATE member
******

Karma: 419
Posts: 5568


Semantically Challenged


WWW
« Reply #13 on: November 02, 2007, 09:52:39 PM »

@ RUI... old buddy...
I have this mod running great in my latest (now pretty stable) MEMU revision (bakercad's version) and it has me thinking of a minor improvement I would like to suggest. So far I am using it to create a menu structure to emulate the category / sub-category structure... with articles only available as sub-menus under the categories assigned to each Category Group. The Category Group names, of course, are just hard-coded in index.php... and the actual categories are created and assigned within them.

Here is a simple display in the default sNews template:


When I view the Category Re-Order List... it is already getting quite long as you can see...


So... do you think you could mod this a bit more to have the categories display by group? I assume it would require creating a way to enter and save "Group" names in the database... and retrieve them so they would display accordingly in index.php and in the Re-order panel. Perhaps it would be possible to use a modified version of the numbering system now used in the mod.


What do you think?  Smiley
Logged

Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Rui Mendes
Testing, Support
sNews Dude
Hero Member
*****

Karma: 180
Posts: 878


sNews1.7


WWW
« Reply #14 on: November 02, 2007, 10:17:57 PM »

I Love it. This is a good ideia.

Awsome improvement my friend.

About "... do you think you could mod this a bit more to have the categories display by group?" Yes I think someway create new tables to control groups or subcategories, don't know how yet. Need to finish my sNews Gallery, this work give me some ideias to do it.

If you see my sNews Gallery I've a function gallery function to control galeries and inside has images, I think I can do transport the ideia to subcategories and multiple areas. This is just new ideia to be develloped.
« Last Edit: November 02, 2007, 10:28:49 PM by Rui Mendes » Logged

Loretteville,Quebec@Canada.
Pages: [1] 2
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!