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] 3 4

Author Topic: Latest news with intro text  (Read 16843 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #15 on: September 20, 2007, 06:23:31 pm »

Yessiree Agent... it sure does. I like it too.  ;D
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

jared351

  • Sr. Member
  • ****
  • Karma: 4
  • Posts: 276
Re: Latest news with intro text
« Reply #16 on: September 25, 2007, 10:15:39 pm »

Great mod Vasile! I'm using it on my sNews demo mods site.... http://jhdezyn.freehostia.com/ Cheers!
Logged

Aysseline

  • Jr. Member
  • **
  • Karma: 4
  • Posts: 66
Re: Latest news with intro text
« Reply #17 on: November 25, 2007, 08:59:23 pm »

Nice addition Vasile but like this one http://snewscms.com/forum/index.php?topic=6065.0 if I follow your code the site doesn't validate
Quote
but don't forget to add <ul> before and </ul> after to correctly display the function when there are no news.
Yes but if you ommited the <li> balise in your code... :P

Here, my way and (like Keyrocks post I put this outside sNews.php file to keep original code clean)
Code: [Select]
// MENU ARTICLES - http://snewscms.com/forum/index.php?topic=5780.0
# 1.6.0 - 1 change, see comment below.
function start_articles($start, $size) {
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";
$result = mysql_query($query);
# 1.6.0 - if / echo / else - added.
if (!$result || !mysql_num_rows($result)) {echo '<li>'.l('no_articles').'</li>';}
else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$text = $r['text'];
$date = date(s('date_format'), strtotime($r['date']));
$categorySEF = find_cat_sef($r['category']);
$title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
echo '<li><span class="art_date">'.$date.'</span></li><li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'</a></li><li class="art_content">'.substr($text,0,105).'...</li>';
}}}

And in my template file (index.php or whatever name you give)
Code: [Select]
<h3>New Articles:</h3><div class="sidebox">
<ul class="start_articles"><?php start_articles(0,3); ?></ul></div>

And in my css file
Code: [Select]
/*- start_articles --------------------------- */
.sidebox .start_articles { list-style-type: none; margin: .1em 1em .5em 30px; padding: 1em 0;  }
.sidebox .start_articles li span.art_date { margin: 0; padding: 0 0 0 18px; font-weight: bold; background: url(../img/articledate.png) 0 0 no-repeat; }
.sidebox .start_articles li a { margin: 0; padding: 0; font-weight: bold; color: #FFA43D;}
.sidebox .start_articles li.art_content { clear: both; margin: .5em 0; padding: 0 0 1em 0; font-size: 90%; text-align: justify; border-bottom: 1px dotted #00CCCC;}

Here a screenshot of the rendering (sorry I work online)
aysseline.com/shots/snews_articles.png

Some explainations (if you need this):
- I make a copy of all the original function and rename it with another name (here "start_articles" but you can name it "Rusnac_articles"  ;D)
- I put a link to snewscms post (hope this doesn't change) to keep infos on the post or MOD
- I comment my css with same name of function and put class also with same name (it's my way no need to follow this to work)
- If you follow my css, you need to customize it with your needs, it's just an example, it done you this structure:
Code: [Select]
<h3>New Articles:</h3>
<div class="sidebox">
<ul class="start_articles">
<li><span class="art_date">25.11.2007. 15:58</span></li>
<li><a href="http://localhost/sNews16/home/test-article-2/" title="home (25.11.2007. 15:58)">Test article 2</a></li>
<li class="art_content">Lorem ipsum at duo fabulas corpora definitiones, torquatos intellegebat vim in. Putent animal eum te. Hin...</li>
<li><span class="art_date">18.11.2007. 10:49</span></li>
<li><a href="http://localhost/sNews16/portfolio/test-article/" title="Portfolio (18.11.2007. 10:49)">Test article</a></li>
<li class="art_content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras venenatis. Fusce facilisis gravida urna. A...</li>
</ul>
</div><!-- end sidebox-->


Note:
I've included Philmoz trick but don't work with my test, but as I don't put break function in my articles example... it maybe the problem.
Logged
sNews 1.6_patched - localhost, Xampp 1.6.2 - XPSP2

Aysseline

  • Jr. Member
  • **
  • Karma: 4
  • Posts: 66
Re: Latest news with intro text
« Reply #18 on: November 26, 2007, 08:46:51 am »

Sorry, forget my stupid post: it doesn't validate anymore if your use <p> balise in article. :-[
Logged
sNews 1.6_patched - localhost, Xampp 1.6.2 - XPSP2

centered

  • Guest
Re: Latest news with intro text
« Reply #19 on: December 11, 2007, 03:27:01 am »

Haven't looked at any other options other than this thread... but I have this validating.  Pretty much it will strip all html tags for use in XML, but that is fine since we can't close this <p> for some god-aweful reason.  Only adds two lines to the original function

Code: [Select]
// MENU ARTICLES
function menu_articles($start, $size) {
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {echo '<li>'.l('no_articles').'</li>';}
else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
// Add the strip here
$text = strip($r['text']);
$date = date(s('date_format'), strtotime($r['date']));
$categorySEF = find_cat_sef($r['category']);
$title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
echo '<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'</a></li>';
// New line here
echo '<li class="para">'.substr($text,0,205).'...</li>';
}}}
« Last Edit: December 11, 2007, 01:41:32 pm by equilni »
Logged

Aysseline

  • Jr. Member
  • **
  • Karma: 4
  • Posts: 66
Re: Latest news with intro text
« Reply #20 on: December 12, 2007, 11:16:55 am »

@equilni:
I tested with your version and this works but the date is not displayed, don't know why. But it's validate. I'm interested to know why in your simple version <p> balises added in my articles aren't displayed and (in my case) can allows validation with no problems.

@ others if you want to use the first version and if you write your articles with <p> balises I rewrited it like this:
Code: [Select]
// MENU ARTICLES
function front_articles($start, $size) {
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {echo '<ul><li>'.l('no_articles').'</li></ul>';}
else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$text = $r['text'];
$date = date(s('date_format'), strtotime($r['date']));
$categorySEF = find_cat_sef($r['category']);
$title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
echo '<p><span class="date">'.$date.'<a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')"><strong>'.$r['title'].'</strong></a></span></p>'.substr($text,0,105).'...</p>';
}}}

Tested and works if you get <p> balises in your articles. Don't forget like orginal of Vasile <ul> for no articles, in this line:
Code: [Select]
if (!$result || !mysql_num_rows($result)) {echo '<ul><li>'.l('no_articles').'</li></ul>';}and put it on div
Code: [Select]
<div><?php menu_articles(0,3); ?></div>
But maybe to works as well you need to add this MOD from Philmoz in your sNews code and even if you don't use Latest news with intro text install it if you're interested by validation issues.

this 2 MOD not tested yet with images in articles...
Logged
sNews 1.6_patched - localhost, Xampp 1.6.2 - XPSP2

centered

  • Guest
Re: Latest news with intro text
« Reply #21 on: December 12, 2007, 01:01:31 pm »

Ahh... thanks.. i didn't see that mod by Philmoz
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Latest news with intro text
« Reply #22 on: December 12, 2007, 02:58:19 pm »

Aysseline -- regarding this
Quote
this 2 MOD not tested yet with images in articles...

The only thing you need to consider is the text limit, since the MOD publishes source code characters. In other words, if you have image code, or script code, or style code, at the beginning of an article, the entire code string will be published by this MOD and each character counts. Example:
Quote
<p>This is the start of my article, and here is <a href="#nogo" title="A short link that leads nowhere">a short link</a> and an image of a bird: <img src="mydomain.con/images/my-images-of-birds-pt2.jpg" alt="One of my bird images" />. Then the article runs on for what seems like for ever, because I always use too many words.</p>
If the limit is set too low, there's a good chance that the break will happen in the middle of the link or image code string, which will break validation and could cause a bunch of other problems. The way to avoid layout problems is, as far as I have found, to do what you have done in your modification of the MOD -- to wrap it all in a div.
(I've done the same ;))

PS. I'm sure you're aware of this already, I just thought I'd share it anyway...
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Article Leads with a Date | Comments Infoline
« Reply #23 on: February 02, 2008, 05:35:12 pm »

[UPDATED]
This function will give you two options display an Info-line under each Article Lead:



Code: [Select]
<?php


// LEAD ARTICLES - last modified Feb.02.08 (keys)
# A modified clone of function menu articles from the snews.php (engine) file.
function lead_articles($start$size) {
# fetching article data (title and text) from articles dbase table
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start$size";
$result mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
        echo '<ul><li>'.l('no_articles').'</li></ul>';
        } else {
$home l('home_sef');
while ($r mysql_fetch_array($result)) {
$text $r['text']; // new string
$date date(s('date_format'), strtotime($r['date']));
$categorySEF find_cat_sef($r['category']);
$title $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);
$comments_query "SELECT * FROM ".db('prefix')."comments WHERE articleid = $r[id] AND approved = 'True'";
$comments_result mysql_query($comments_query);
$comments_num mysql_num_rows($comments_result);
echo '<p class="artitle"><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.'"><strong>'.$r['title'].'</strong></a></p><p class="artlead">'.substr($text,0,75).'...</p><p class="artinfo">'.$date.'&nbsp;-&nbsp;<span class="uline">'.$comments_num.' '.l('comments').'</span></p>';
}
}}


?>


And... to style it as shown, add the following to your style.css file and adjust the declarations to your needs:

Code: [Select]
.artitle { margin-top: 16px; }
.artitle a { text-decoration: none; line-height: 0; }
.artlead { font: 12px arial; color: #000; line-height : 1.3em; }
.artinfo { padding-bottom: 3px; border-bottom: 1px dashed #c9c9c9; font: 11px arial; color: #808080; }
.uline { text-decoration: underline; }
« Last Edit: February 03, 2008, 04:51:45 am by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 938
    • cssanarchy.com
Re: Latest news with intro text
« Reply #24 on: February 02, 2008, 08:16:58 pm »

can we see preview of this mode.I do not want to install somthing i cant to understand 100%.Its great to see some preview or some screanshot of mods...i guess this is great mod key :)
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥

Joost

  • Guest
Re: Latest news with intro text
« Reply #25 on: February 02, 2008, 08:38:11 pm »

can we see preview of this mode.I do not want to install somthing i cant to understand 100%.Its great to see some preview or some screanshot of mods...i guess this is great mod key :)

Output is something like this (for you to style):

Option 1

<p class="leads"><a href="link-to-article" title="redundant Title"><strong>Title <strong></a>
Teaser containing 140 characters. Teaser containing 140 characters. Teaser containing 140. characters Teaser containing 140 characters. Yes</p> 20-08-2008 - Comments: 20

Option 2

<p class="leads"><a href="link-to-article" title="redundant Title"><strong>Title <strong></a>20-08-2008 - Comments: 20</p>
Teaser containing 140 characters. Teaser containing 140 characters. Teaser containing 140. characters Teaser containing 140 characters. Yes</p>

Option 2 is missing element 'p' if I am not mistaken.




Logged

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 938
    • cssanarchy.com
Re: Latest news with intro text
« Reply #26 on: February 02, 2008, 09:06:05 pm »

Thanx joost.I do not like this mod sory key.I do not want my snews looks like phpnuke or worst jomla  ;D .Like The Tick post on http://snewscms.com/forum/index.php?topic=6013.45 i also want to see mod like this http://quommunication.com/demo/news/
used in wordpres with Latest news and only date posted and comment.I not liked news intro.That for me looks so agly and make problems in designs like 10 last articles or 10 last post. This is what user "The Tick" means. also....This mod shuld use
Code: [Select]
<?php popular_articles(15);?> or somthing similar like Last 15 news itc.itc

For easy understanding what i`m  talking about i made some picture
 
« Last Edit: February 02, 2008, 09:07:56 pm by Sasha »
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #27 on: February 03, 2008, 04:21:27 am »

Thanx joost.I do not like this mod sory key.I do not want my snews looks like phpnuke or worst jomla  ;DFor easy understanding what i`m  talking about i made some picture...

OK... then what you are looking for is NOT this mod. This mod... if you look back to Vasil's first post in this topic... is meant to display the first 140 characters of the article under the article title... and that is why it is called an Intro Text mod. :)

What you are looking for is to add an info-line under the article title in the default // MENU ARTICLES function in the snews.php file:



... so here is the default // MENU ARTICLES function, with the NEW STRINGS added in... to display as shown in the image (above):

Code: [Select]
<?php


// MENU ARTICLES
function menu_articles($start$size) {
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start$size";
$result mysql_query($query);
if (!$result || !mysql_num_rows($result)) {echo '<li>'.l('no_articles').'</li>';}
else {
$home l('home_sef');
while ($r mysql_fetch_array($result)) {
$date date(s('date_format'), strtotime($r['date']));
$categorySEF find_cat_sef($r['category']);
$title $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);
# 3 NEW STRINGS - fetch number of comments for each article from comments dbase table
$comments_query "SELECT * FROM ".db('prefix')."comments WHERE articleid = $r[id] AND approved = 'True'";
$comments_result mysql_query($comments_query);
$comments_num mysql_num_rows($comments_result);
# 1 NEW STRING - replaces default string below it
echo '<p class="artitle"><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.'"><strong>'.$r['title'].'</strong></a></p><p class="artinfo">'.$date.'&nbsp;-&nbsp;<span class="uline">'.$comments_num.' '.l('comments').'</span></p>';
# default string
//echo '<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'</a></li>';
}}}


?>


And... to style it as shown, add the following to your style.css file and adjust the declarations to your needs:

Code: [Select]
.artitle { margin-top: 14px; }
.artitle a { text-decoration: none; line-height: 0; }
.artinfo { padding-bottom: 3px; border-bottom: 1px dashed #c9c9c9; font: 11px arial; color: #808080; }
.uline { text-decoration: underline; }

DATE - If you want the date to display differently than shown... you only need to change the "Date Format" in the SETTINGS >> TIME & LANGUAGE settings panel.

PS: I also updated the "Lastest news with intro text" mod I posted above so that it's using the same styling as this one.  ;)
« Last Edit: February 03, 2008, 04:55:34 am by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Latest news with intro text
« Reply #28 on: February 03, 2008, 01:34:24 pm »

Good job Keys!
Now, if you tend to use links, images or other details that use longish code strings, there's one more thing you might want to consider with this mod. strip_tags.

Here's my mod of the mod (of the mod), with strip_tag included. I've set mine to exclude img and a from the shortened text. If you want other things excluded (or added), look at the second part of the strip_tag bracket. That line includes the tags that you do not want stripped out of the article. Any tags not included in that line will be stripped.

The whole modified code, with my change in red:
Quote
<?php // LEAD ARTICLES - last modified Feb.02.08 (keys) $finetext added 02.08 (fredk)
# A modified clone of function menu articles from the snews.php (engine) file.
function lead_articles($start, $size) {
   # fetching article data (title and text) from articles dbase table
   $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC LIMIT $start, $size";
   $result = mysql_query($query);
   if (!$result || !mysql_num_rows($result)) {
           echo '<p>'.l('no_articles').'</p>'; //why use a list for this?, a paragraph will do just fine
           } else {
      $home = l('home_sef');
      while ($r = mysql_fetch_array($result)) {
      $text = $r['text'];
      $finetext = strip_tags($text, '<abbr><acronym><blockquote><cite><h1><h2><h3><h4><h5><dl><dt><dd><ul><li><ol><p><hr /><br /><strong><em>');// new string
      $date = date(s('date_format'), strtotime($r['date']));
      $categorySEF = find_cat_sef($r['category']);
      $title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
      $comments_query = "SELECT * FROM ".db('prefix')."comments WHERE articleid = $r[id] AND approved = 'True'";
      $comments_result = mysql_query($comments_query);
      $comments_num = mysql_num_rows($comments_result);
   echo '<h5><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.'"><strong>'.$r['title'].'</strong></a></h5><p class="small">'.$date.'&nbsp;&nbsp;|&nbsp;&nbsp;'.$comments_num.' '.l('comments').'</p><p class="small">'.substr($finetext,0,120).'...</p>'."\r\n".'<p>[<a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="Full story">Permalink</a>]</p>'."\r\n"; /*A few HTML tags changed but how you want to present the short article is up to you. Added a link at the end of the article to full story. (fredk, 03.08)*/
      }
}}
?>

As noted at the end of the code, presentation (including which way to mark up the short story output is up to each and every one. The tags used in my modded code are merely examples -- it's how I mark up my output. ;)
« Last Edit: February 03, 2008, 01:37:12 pm by Fred K (agentsmith) »
Logged

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 938
    • cssanarchy.com
Re: Latest news with intro text
« Reply #29 on: February 03, 2008, 08:46:15 pm »

Hey Key!! Thx a lot :).Karma for ya  ;D
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥
Pages: 1 [2] 3 4