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.

Pages: [1] 2

Author Topic: [MOD] Show In Front  (Read 6871 times)

H.A.C

  • Jr. Member
  • **
  • Karma: 20
  • Posts: 86
  • i love snews community for its great members
    • Chasoft Corporation
[MOD] Show In Front
« on: November 07, 2007, 05:15:31 pm »

miniMOD: Show In Front
Description:
I have a site with many categories (for example: they are softwares, scripts, ebooks and help). I want to display all newly added articles of softwares, scripts, ebooks and I don't want the newly added articles of help showed on home (I turn on "show on home" feature and all the articles from all categories show). If I use "hidden articles mod", the articles are absolutely hidden. But i still want my articles in help are listed in sitemap, in search and in help when visitor clicks help category and so on.

This is the situation with my own site at http://www.chasoft.net. And this is my solution, very simple. Hope it useful to someone. This is my solution for my need. And if it don't fit your needs, you can extend it.

To use this mod, you have to enable "show on home" feature in admin panel and enable "show in front" feature (in customize section) when you create a new article. And I think this mod is compatible to "hidden article mod" because if you turn on "hidden feature" then it will just override my mod.

Okie, let's go.

1. database change

Code: [Select]
--standard mysql query
ALTER TABLE `articles` ADD `show_in_front` char(3) NOT NULL DEFAULT 'YES'

Code: [Select]
--mysql query using table PREFIX_
ALTER `TABLE PREFIX_articles` ADD `show_in_front` char(3) NOT NULL DEFAULT 'YES'

2. language variable (snews.php)
- it will be used inside administration page

Code: [Select]
$l['show_in_front'] = 'Show the article in front page';
3a. // ARTICLES FORM
add this line
Quote
      echo html_input('checkbox', 'show_in_front', 'dt', 'YES', l('show_in_front'), '', '', '', '', $frm_show_in_front, '', '', '', '', '');
just above
Quote
   echo html_input('checkbox', 'display_title', 'dt', 'YES', l('display_title'), '', '', '', '', $frm_display_title, '', '', '', '', '');

3b. // ARTICLES FORM (newly added part- thanks armen for his reply)

locate this:
Code: [Select]
$frm_publish = $r['published'] == 1 ? 'ok' : '';
just above, add this line
Code: [Select]
$frm_show_in_front = $r['show_in_front'] == 'YES' ? 'ok' : '';
4. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/
just below this line
Quote
     $display_title = $_POST['display_title'] == 'on' ? 'YES' : 'NO';
add this
Quote
   $show_in_front = $_POST['show_in_front'] == 'on' ? 'YES' : 'NO';


5. /*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/
Find and add the text in blue
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, show_in_front) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta', '$show_in_front')");
                  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', show_in_front = '$show_in_front' WHERE id = '$id' LIMIT 1;");

6. // CENTER
Quote
         if (s('display_new_on_home') == 'on') {$query_articles .= $use_cat_id != 0 ? " AND category = $use_cat_id" : ' AND show_in_front = "YES"';}
         else {$query_articles .= " AND category = $use_cat_id";}

That's all.
« Last Edit: November 08, 2007, 03:23:51 pm by H.A.C »
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!

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
Re: [MOD] Show In Front
« Reply #1 on: November 08, 2007, 11:35:24 am »

1. You forgot this:

In // ARTICLES FORM, above

Code: [Select]
$frm_publish = $r['published'] == 1 ? 'ok' : '';
You need to add:

Code: [Select]
$frm_show_in_front = $r['show_in_front'] == 'YES' ? 'ok' : '';
To display correct status of the checkbox when editing an existing article.

2. And in SQL strings with 'prefix_':

It should be:

Code: [Select]
alter table prefix_articles add show_in_front char(3) NOT NULL Default 'NO' ;

Set NO or YES as you like.

Old string gives an error because of unnessesary quotes.

Thank you for your mod and a perfect idea how to manage my newest project.
« Last Edit: November 08, 2007, 05:57:58 pm by Armen »
Logged
Now ogres, oh, they're much worse. They'll make a suit from your freshly peeled skin. They'll shave your liver, squeeze the jelly from your eyes... Actually, it's quite good on toast.

H.A.C

  • Jr. Member
  • **
  • Karma: 20
  • Posts: 86
  • i love snews community for its great members
    • Chasoft Corporation
Re: [MOD] Show In Front
« Reply #2 on: November 08, 2007, 02:56:30 pm »

Armen, thanks for your reply. I missed that line of code. I'll update my post at once.
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!

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
Re: [MOD] Show In Front
« Reply #3 on: November 08, 2007, 05:34:34 pm »

One more thing which will help to identify "show_in_front" marked artcles in admin article list:

So it would look like this:

  Articles ---------------------------------------------------------------------
  article1 View Edit
  article2 View Edit Status: Show in front page
  article3 View Edit

Step-by-step:

Add language variable:

Code: [Select]
$l['frontpage'] = 'Show in front page';
Find:

Code: [Select]
if ($r['published'] == 0) {echo  l('divider').' ['.l('status').' '.l('unpublished').']';}
And right after it insert:

Code: [Select]
if ($r['show_in_front'] == "YES") {echo  l('divider').' ['.l('status').' '.l('frontpage').']';}
Logged
Now ogres, oh, they're much worse. They'll make a suit from your freshly peeled skin. They'll shave your liver, squeeze the jelly from your eyes... Actually, it's quite good on toast.

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: [MOD] Show In Front
« Reply #4 on: December 13, 2007, 04:29:26 pm »

Excellent MOD - provides for basic control over what is promoted to entry page (home) and what's not right at site editor hands. No need for tricks at index.php.

P.S. Thanx Ayesseline for reminding of this one.
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Re: [MOD] Show In Front
« Reply #5 on: December 13, 2007, 11:48:38 pm »

what an excellent MOD, cheers HAC well done :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Martin2007

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
Re: [MOD] Show In Front
« Reply #6 on: December 26, 2007, 03:59:46 am »

I am reading this MOD and quite interested and am willing to implement. I just one question. When you choose "show in front" for an article:

1. Does it gets transfered from the intended category to the "home" category?
2. If I applied the [break] in composing the article will this be recognized when shown in front?

I will appreciate a reply for this wonderful MOD.

Martin
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: [MOD] Show In Front
« Reply #7 on: December 26, 2007, 09:32:49 am »

1. No, it doesn't get transfered to different category.
2. [break] as well works as usual.

Only and intended change will be that not all but just 'show in front' articles from all categories will be shown at home. Without this mod all articles from all categories will be shown on home. With this mod You simply have control of what is being shown on home.
Logged

Martin2007

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
Re: [MOD] Show In Front
« Reply #8 on: December 26, 2007, 12:59:51 pm »

Thanks codetwist for your reply. That is helpful. What if I am using another customized page like Frontpage as Home (that I created through sNews but hide it from the navigation menu pages, will this feature take effect as well? Thanks for any reply.

Martin
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: [MOD] Show In Front
« Reply #9 on: December 26, 2007, 01:41:30 pm »

If that is a custom sNews page then You will need more modifications developed/used for articles to appear on it.
Logged

mfaraklit

  • Newbie
  • *
  • Karma: 1
  • Posts: 20
Re: [MOD] Show In Front
« Reply #10 on: March 20, 2008, 09:28:55 am »

what exactly i want is to show new articles according to categories in Front page(home). ( for example have 3 categories and then draw a table width 3 cols. and showing them according to cats)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] Show In Front
« Reply #11 on: March 20, 2008, 01:18:01 pm »

what exactly i want is to show new articles according to categories in Front page(home). ( for example have 3 categories and then draw a table width 3 cols. and showing them according to cats)

You could take a look at the code in the Sitemap function. It displays links to articles by category. You could likely create a custom function using the sitemap code for the bits you need.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

jackp

  • Newbie
  • *
  • Karma: 2
  • Posts: 32
  • But you said "Stick it there!!"
    • Tim Chard - myEmote
Re: [MOD] Show In Front
« Reply #12 on: March 24, 2008, 05:06:59 am »

Ahhh...

See all you have to do is look. Will implement this mod right away as it is EXACTLY what I have been looking for. sNews is just getting better every minute.

Thanks HAC for creating this Mod and everyone else for extra fixes. Am happy now. (almost)

Jackp
Logged

slemborg

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 82
Re: [MOD] Show In Front
« Reply #13 on: April 29, 2009, 10:54:52 pm »

Old topic, but I also need a mod like this and will try it out, hopefully it works with snews 1.7
Logged

slemborg

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 82
Re: [MOD] Show In Front
« Reply #14 on: April 30, 2009, 01:11:50 am »

I tried, but it didn't work for me in sNews 1.7
Logged
Pages: [1] 2