Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2 3 4

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

Vasile Rusnac

  • Newbie
  • *
  • Karma: 7
  • Posts: 49
Latest news with intro text
« on: August 30, 2007, 10:20:18 AM »

Hi, I hope this will be a small addition to those wishing to have a bit more extended menu articles function.

This mode will replace the list items of news from the menu_articles function with something similar to: "date" "news title" "short intro".

Example:


To get this pour some coffee and follow these steps:

1. Backup your snews.php

2. Find the line from // MENU ARTICLES :
Code: [Select]
$date = date(s('date_format'), strtotime($r['date']));
3. Add just before it:
Code: [Select]
$text = $r['text'];
4. Find the following line  from // MENU ARTICLES :
Code: [Select]
echo '<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'</a></li>';
5. Simply replace it with the following:
Code: [Select]
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 />';
where 105 is the number of characters to be displayed as introtext.
NOTE - Aug.15.08: For French dates... see Sven's solution.

6. include
Code: [Select]
<div><?php menu_articles(0,3); ?></div> in your index page

7. You can change styles in your css file to suit your needs.

You can leave intact
Code: [Select]
echo '<li>'.l('no_articles').'</li>'; but don't forget to add <ul> before and </ul> after to correctly display the function when there are no news.

Known issues :)
- if you use break function to divide your story and it is in the first 105 displayed characters then it wont work :(
« Last Edit: August 15, 2008, 08:47:21 PM by Keyrocks »
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
Re: Latest news with intro text
« Reply #1 on: August 30, 2007, 11:00:40 AM »

Nice feature, Vasil... Will have a try out, as soon as time permits me. Thanks for your addition, and a karma point is awarded :)
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

Dobri

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
    • http://dobri.biz
Re: Latest news with intro text
« Reply #2 on: August 30, 2007, 03:18:26 PM »

Vary nice!

Than you. It is vary usefull.  ;)
Logged

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
Re: Latest news with intro text
« Reply #3 on: August 30, 2007, 03:59:24 PM »

Smart. Very smart. Thanks!  :)

Rui Mendes

  • Development,Testing, Support
  • sNews Dude
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1039
  • sNews1.7
    • Comunidade Portuguesa
Re: Latest news with intro text
« Reply #4 on: August 30, 2007, 11:10:57 PM »

I agree with you agentsmith

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

Vasile Rusnac

  • Newbie
  • *
  • Karma: 7
  • Posts: 49
Re: Latest news with intro text
« Reply #5 on: August 31, 2007, 02:22:03 PM »

Thank you guys for appreciation. it is good to know that you find it ok.
cheers
Logged

philmoz

  • High flyer
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 2001
    • fiddle 'n fly
Re: Latest news with intro text
« Reply #6 on: September 01, 2007, 06:14:45 AM »


5. Simply replace it with the following:
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 />';
where 105 is the number of characters to be displayed as introtext.
Known issues :)
- if you use break function to divide your story and it is in the first 105 displayed characters then it wont work :(


try
Code: [Select]
substr(str_replace('[break]','','$text'),0,105)untested, but don't see why it shouldn't work.
« Last Edit: September 01, 2007, 06:32:13 AM by Phil Martin (Philmoz) »
Logged
Of all the things I have lost, it is my mind that I miss the most.

brauck

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 18
  • Posts: 572
    • http://www.hbw-webdesign.nl/
Re: Latest news with intro text
« Reply #7 on: September 01, 2007, 05:20:48 PM »

Nice addition Vasile. Thanks
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6249
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #8 on: September 02, 2007, 05:06:58 PM »

MOD OPTION 1 - for Template-specific Use Only:
One of the sNews development objectives is to keep the snews.php (engine) file separated from any theme or template styling. That way you can continue to add core modifications to your snews.php file and use it with any template or theme. This option allows you to do that... by creating a new function - based on a copy of // MENU ARTICLES - to do the same work without affecting the default // MENU ARTICLES function in the snews.php file. This also allows you to display the default menu articles list as well as the "Latest News with intro text".

1)  Take a copy of the complete  // MENU ARTICLES function and paste it into a new PHP file... and wrap it with opening and closing PHP-tags.
2)  Save this file into your sNews site's root directory (along side of the index.php and snews.php files) as lead_articles.php.
3)  Change the name of the function to function lead_articles($start, $size).
4)  Modify the function as shown in Vasil's Mod.
5)  Add an "include" statement at the top of your template (index.php) file, just below the "include" statement for your snews.php file.

MOD OPTION 2 - with Bakercad's Template Switcher (Admin Panel) Mod:
Bakercad's Template Switcher Mod allows you to have several templates (themes) located in a separate folder and you can switch site-wide templates from the Settings Admin Panel. If you have installed the Template Switcher Mod, and you want use this Latest news with intro text mod within a specific template, (as I do)... you can apply it this way.

1)  same as above in Option 1.
2)  Save this file in your template folder as lead_articles.php.
3)  same as above in Option 1.
4)  same as above in Option 1.
5)  Add an "include" statement to include the new file, just below the "include" statement for your snews.php file... located in the index.php file in your sNews site root:

Quote
<?php session_start();
   include('snews.php');
   # INCLUDE template-specific file for lead articles only
   include ('templates/main1/lead_articles.php');
   
   if(file_exists('templates/'.s('template').'/index.php')){
      include('templates/'.s('template').'/index.php');
   }
   else{
      mysql_query("UPDATE ".db('prefix')."settings SET value = 'default' WHERE name = 'template'");
      include('templates/default/index.php');
   }
?>

Be sure to change the template folder name to whichever template folder the file is located in... the script above shows a template folder name of main1 as an example only.
« Last Edit: September 02, 2007, 05:36:48 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
Re: Latest news with intro text
« Reply #9 on: September 02, 2007, 05:44:50 PM »

Good tip, key's. I forgot to remember that, it's something that should always be considered (when including mods in a template), at least for publicly released templates. I've put this in my latest template, Osaka, which now is released.

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6249
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #10 on: September 02, 2007, 06:41:20 PM »

@ Fred K... For some reason, the article's "post date" does not display at all with this mod. And, come to think of it... all that displays (in my current  'over-weight' project) article info-line is the "Comments (1)" and "Edit" link... maybe one of my recent mods has disabled some of the info-line info... tho I have checked the info-line and tags function and all appear to be functional.  :-\
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
Re: Latest news with intro text
« Reply #11 on: September 02, 2007, 08:45:08 PM »

Key's -- I haven't run into that problem. In the standard sNews context it works as it should. So I can only assume that the problem is caused by some conflict with either one of your special mods or possibly the template switcher -- I wouldn't know since I haven't tried those together yet.

You can see that it works in a standard sNews 1.6 here (link removed).
« Last Edit: June 09, 2009, 01:20:26 PM by Fred K (agentsmith) »
Logged

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6249
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #12 on: September 03, 2007, 04:49:38 PM »

Thanks Fred... yes... just tested my Mod Option 1 in my sNews 1.6 with Template Switcher Mod Only project... and it displays just fine there. My problem is obviously related to incompatibility with one of of my mods. Back to the drawing board.  :P

UPDATE: September 07.07:
After 4 days of working through my disappearing date-line problem... I finally discovered that it was related to one specific template that I was developing... for inclusion using Bakercad's Template Switch Mod. It is a rather complicated template, using fixed header and footer with a scrolling content area in the middle. I need this type of template so that it can be used in one site with several other applications, including a GIS module where viewers can view GIS overlays... similar to the way Google Earth works but customized for a specific geographical area with the GIS data-sets tied to the overlays. And... it works fine with two themes already created. It just wasn't working with a third... more complicated one.

I would create fresh articles in a set of fresh database tables using the default template. The date-line would display fine in the article info-lines and in the "Latest news with intro text". Switching to my problem template would cause the date-lines to disappear. Changing back to the default template resulted in the date-lines remaining invisible. When I refreshed (deleted and re-created) the database tables... and started over with the same articles using the default template... the date-lines were visible again. Obviously, just changing the template altered the data in the tables somehow so that the date-line information would not display. I compared the data in the tables from 2 different (exact) databases and could not see any difference in the data.

The solution to my problem... of course... is to not use the problem template. However, this leaves me wondering how one template can alter the database data... particularly as all of the data-work is done by the functions in snews.php... not by the template's files.  ???
« Last Edit: September 07, 2007, 06:10:31 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6249
  • Semantically Challenged
    • snews.ca
Re: Latest news with intro text
« Reply #13 on: September 20, 2007, 04:05:42 PM »

IF USING THUMBNAIL IMAGES AT THE START OF AN ARTICLE:
I came across this unique (or not so unique) problem yesterday while applying the Latest News with Intro Text mod to a new project based on my current sNews 1.6 Enhanced package. That package uses Mattonik's Image Links Panel... which allows the Admin to insert links to images, or thumbnail images linking to larger images... into an article.

If you have inserted a larger image... or thumbnail linked to the larger image... and a lead-in for that article is listed by the Latest News with Intro Text mod... the image link string in the article's textarea will be broken or split in the lead-in text. This causes the image link to apply to everything that follows the function-call string in your index.php file INCLUDING the center function string and... while this occurs... you are barred from putting your cursor into the article edit textarea to edit the content for that article.

The only solution is to substantially increase the number of characters displayed in each article lead-in from the default setting of 105. To close the image link string for a thumbnail at the top of an article... and have a reasonable amount of lead-in text display with the thumbnail, I found it necessary to increase the character max the last line of the function) to at lease 275. Depending on the width of the division in which your article lead-ins display, you will need to try different settings until you get it just right.

When using this mod in conjunction with Mattonik's Image Links insertion mod... I would advise against inserting a full-sized image anywhere near the top of an article's content. Insert it well down in the article... say after the second paragraph. Otherwise... if it is near or at the top... the image link will be split and cause the same problem trying to display within the article lead-in.

I hope this is useful.  :)
« Last Edit: September 20, 2007, 04:12:59 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 134
  • Posts: 2806
Re: Latest news with intro text
« Reply #14 on: September 20, 2007, 04:54:59 PM »

Doug,
This isn't limited to images actually. The Latest News With Intro Text Mod pulls the first (n) characters of your article source code, e.g not just the text you've written including spaces and linebreaks but all code characters including html tag characters. Which means that this behavior appears if you have an image at the beginning of your article, or one or more links or emphasis tags, etc. The mod pulls in the source code, not user entered text -- that's the best way to put it I think.

So when using the mod, as you point out, think about what the first paragraphs contain and what effect it might have with the mod in use. Testing is required to understand how it works, imho.

But it works nicely. ;)
Pages: [1] 2 3 4