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 16842 times)

Keyrocks

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

Quote from: Sasha
Hey Key!! Thx a lot :).Karma for ya  ;D

Thanks for the karma... always a treat to receive. I hope it works for ya... especially with the "bonus" mods from Fred K.  ;D

@ Fred... Thanks for the mod to the modded mod of the modded mod... (bu bu huma hu ma ma...) ... amazing how a mod can grow in 24 hours or less.
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 #31 on: February 04, 2008, 07:12:40 am »

hehehe Key...i m going to try this mod after i finish my Blog designs....soon
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 ♥

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Latest news with intro text
« Reply #32 on: August 13, 2008, 12:29:52 pm »

Great Mod... which has been (almost successfully) on my rédacteur Web* site (see Articles Tab in the bottom).
For some reasons I get dates in english format.
I thought having setlocale would solve the issue:
Quote
   while ($r = mysql_fetch_array($result)) {
   $text = $r['text'];
   setlocale(LC_ALL, 'fr_FR');
      $date = date("d M", strtotime($r['date']));
but nope.
That's pretty weird since the whole blog display date in french.

*Yeap Dudes: I'm spamming the forum for BL reasons.
« Last Edit: August 13, 2008, 04:38:03 pm by Sven »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Latest news with intro text
« Reply #33 on: August 13, 2008, 04:51:51 pm »

okey this is it:
Quote
$date = date(s('date_format'), strtotime($r['date']));
but it gives:
Quote
07.08.2008 @ 15:38
in the backend date preferences are :
d.m.Y @  H:i
How to have this bloody date written:
Jeudi 7 août 2008 ???

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #34 on: August 13, 2008, 07:33:58 pm »

okey this is it:
Quote
$date = date(s('date_format'), strtotime($r['date']));
but it gives:
Quote
07.08.2008 @ 15:38
in the backend date preferences are :
d.m.Y @  H:i
How to have this bloody date written:
Jeudi 7 août 2008 ???

I looked around for a way of converting this to display in French.
I came across this script and modified it to show the Current Date in French.
You can paste the function in your snews.php file... somewhere before the Administration functions start.
Then paste the echo string provided (after the function) wherever you want the current date displayed... and see how this works.
Perhaps you can use it as-is, or modify it more to get its variables from the date format in the Settings table.

Code: [Select]
<?php

// CURRENT DATE IN FRENCH
// based on a function made 06.30.98 by [email protected]
// modified by keyrocks: Aug.13.08
function date_fr($timestamp$mode) {
$result "";
$dval date("w") - 1;   // "w" = current day-name value
$nval = (int) date("d");        // "d" = current day-number value
$mval date("m") - 1;          // "m" = current month-name value
$year date("Y");              // "Y" = current year value (2008)

// Values in the arrays can be changed to another language.
// ---------------------------------------------------------
$day = array("lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche");
$sday = array("lun","mar","mer","jeu","ven","sam","dim");
$month = array("janvier","f&#38;#233;vrier","mars","avril""mai","juin","juillet","ao&#38;#251;t","septembre","octobre","novembre","d&#38;#233;cembre");
$smonth = array("jan","f&#38;#233;v","mars","avr","mai","juin","juil","ao&#38;#251;t","sept","oct","nov","d&#38;#233;c");

// Output Mode Options
switch ($mode) {
case "Long":    // Prints: Mercredi 13 Août 2008
$result ucfirst($day[$dval]).$nval ".ucfirst($month[$mval])." ".ucfirst($year);
break;

case "long":    // Prints: mercredi 13 août
$result "$day[$dval] $nval $month[$mval]";
break;

case "Short": // Prints: Mer 13 Août
$result ucfirst($sday[$dval]).$nval ".ucfirst($smonth[$mval]);
break;

default:        // Prints: mer 13 août
$result "$sday[$dval] $nval $smonth[$mval]";
}
return 
$result;
}



/* USE THE FOLLOWING STRING WHERE YOU WANT THE CURRENT DATE TO APPEAR
To change the current date output mod, change the 2nd value ($mode):
"Long", "long", or "Short". Empty value dDisplays default $mode.
-----------------------------------------------------------------------------*/
echo date_fr(filemtime(basename($PHP_SELF)),"Long");

?>


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: Latest news with intro text
« Reply #35 on: August 14, 2008, 08:40:50 am »

Thank you so much Doug!
I thought it would be simpler.
I don't know why by I had to change the char encoding (from mumeric to text entities) to get the accented french letters being displayed correctly. Otherwise there were displayed as this:
Quote
Jeudi 14 Ao&#251;t 2008
This is the code that works:
Quote
   $day = array("lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche");
   $sday = array("lun","mar","mer","jeu","ven","sam","dim");
   $month = array("janvier","f&eacute;vrier","mars","avril", "mai","juin","juillet","ao&ucirc;t","septembre","octobre","novembre","d&eacute;cembre");
   $smonth = array("jan","f&eacute;v","mars","avr","mai","juin","juil","ao&ucirc;t","sept","oct","nov","d&eacute;c");

EDIT: but the code display the current date, not the article date. :-[
« Last Edit: August 14, 2008, 12:27:33 pm by Sven »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #36 on: August 14, 2008, 03:03:24 pm »

1 - I don't know why by I had to change the char encoding (from mumeric to text entities) to get the accented french letters being displayed correctly.
2 - EDIT: but the code display the current date, not the article date. :-[


1 - That might have something to do with your charset setting. I didn't have that problem with my test project... My database is set up using utf8_unicode_ci for both MySQL connection collation and dbase collation... and the default charset (in Settings >> Time & Locale Settings) is UTF-8.

2 - Yes... this is because I modified the values in the variables at the top to display that way.
The trick now is to (maybe) modify this script so that it can convert the date being displayed in the infoline by this variable string in function center()
        $a_date_format = date(s('date_format'), strtotime($r['date']));
... which means... basically... converting $r['date'] (fetched from the articles table) to fit into the variables in the french conversion script... somehow.
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: Latest news with intro text
« Reply #37 on: August 14, 2008, 04:16:55 pm »

1 - That might have something to do with your charset setting. I didn't have that problem with my test project... My database is set up using utf8_unicode_ci for both MySQL connection collation and dbase collation... and the default charset (in Settings >> Time & Locale Settings) is UTF-8.
Same for me  ::)
2 - The trick now is to (maybe) modify this script so that it can convert the date being displayed in the infoline by this variable string in function center()
        $a_date_format = date(s('date_format'), strtotime($r['date']));
... which means... basically... converting $r['date'] (fetched from the articles table) to fit into the variables in the french conversion script... somehow.
still don't dig why if it works in function center() it doesn't work here.???
As my calendar Mod works well I've tried this:
Quote
   setlocale(LC_ALL, 'fr_FR');
      $categorySEF = find_cat_sef($r['category']);
      $title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
      echo '<p><span class="date">'.strftime("%b", strtotime($r['date'])).'</span><br /><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'<span class="or">&#160;&raquo;</span></a></p>'.substr($text,0,200).'...</p>';
setlocale and date strftime should work here, but nope!
This is a complete mystery for me.

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Latest news with intro text
« Reply #38 on: August 14, 2008, 06:02:15 pm »

I needed this icon a few times here, on forums... :P
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Latest news with intro text
« Reply #39 on: August 14, 2008, 06:29:40 pm »

Hi Mr Fun
I thought you came to give an advice. ;D
Glad you enjoy seeing my smiley. ;)

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Latest news with intro text
« Reply #40 on: August 14, 2008, 06:58:06 pm »

OK!

I looked at php.net:
For function strtotime. It returns current time if second parameter is not supplied.
 
...relative to the timestamp given in now , or the current time if now  is not supplied.

now - is the second parameter for our function... look at syntax.
« Last Edit: August 14, 2008, 06:59:44 pm by funlw65 »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Latest news with intro text
« Reply #41 on: August 15, 2008, 10:05:24 am »

finally that was it:
Quote
setlocale(LC_ALL, 'fr_FR.UTF8');
      echo '<p><span class="date">'.strftime("%A %d %B", strtotime($r['date'])).'</span><br /><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'<span class="or">&#160;&raquo;</span></a></p>'.substr($text,0,200).'...</p>';
Quote
Despite having this function:
Quote
function connect_to_db() {
   $db = mysql_connect(db('dbhost'), db('dbuname'), db('dbpass'));
   mysql_query("SET CHARACTER SET 'UTF8'");
   mysql_query("SET NAMES 'utf8'");
   mysql_select_db(db('dbname')) or die(db('dberror'));
}
(code comin from Brother Mo)
utf-8 wasn't recognized.

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #42 on: August 15, 2008, 02:56:44 pm »

@ Sven... If you have a solution (above) for this problem... it would be useful (for others) if you provide some more information about your solution.
1 - What version of sNews does this apply to?
2 - What changes did you make that are different than the default code?
3 - Which function(s) were the changes made in... and what would we search for to find the change locations?

A good way to demonstrate your modifications is to comment out the default strings, make a comment to show what is being added in, above the new string(s) that replaces the default string(s) for each change location. Then post them in code blocks so that the rest of us can then search for these locations and make the necessary changes if we want to test and use your mod.

And... if this does work, we should make sure we have it posted in the Mods & Addons section.  ;)
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: Latest news with intro text
« Reply #43 on: August 15, 2008, 05:18:43 pm »

Hello Mr Keyrocks
well, I must say "I ain't done nothin man!"
I just applied setlocale to french / UTF-8 and strftime parameters for the echo.
That's no big deal.
I don't think there's a bug in Vasile Rusnac's code or in sNews. I just said I couldn't have dates localized in this Mod and never found why it works with my articles pages and not there. ???
This was the original code from Vasile:
Quote
echo '<span class="yourdatestyle">'.$date.'</span> <a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')"><strong>'.$r['title'].'</strong></a><span class="yourtextstyle">'.substr($text,0,105).'...</span><br />';
$date as well as r$date were displaying english dates.
You both, (Mr Fun and Mr Keyrocks) just gave a clue: if it works in the calendar Mod, I just have to apply (almost) the same code.
- setlocale to display the date in french
- UTF-8 to say (once gain!) my site is encoded that way.
- strftime with its parameters for dates formatting,
which gives:
Quote
setlocale(LC_ALL, 'fr_FR.UTF8');
 echo '<p><span class="date">'.strftime("%A %d %B", strtotime($r['date'])).'</span><br /><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'<span class="or">&#160;&raquo;</span></a></p>'.substr($text,0,200).'...</p>';
So you see, it's just Inspector Sven's enchilada to get rid of this problem.

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #44 on: August 15, 2008, 08:43:24 pm »

Hello Mr Keyrocks
well, I must say "I ain't done nothin man!"
I just applied setlocale to french / UTF-8 and strftime parameters for the echo.
That's no big deal.
I don't think there's a bug in Vasile Rusnac's code or in sNews. I just said I couldn't have dates localized in this Mod and never found why it works with my articles pages and not there. ???

 :P OK... (I am awake now). Here I was searching for the code in a default 1.6 project and coudln't find it... naturally... this (Vasile's) mod ain't in there. I thought you weren't getting French dates anywhere.  :-[

I added a note with a link to your post in Vasile's original mod post so anyone else will pick up on it right away when first installing it.  :)
« Last Edit: August 15, 2008, 08:49:04 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Pages: 1 2 [3] 4