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]Read More link in shortened article (snews1.6)  (Read 10050 times)

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[MOD]Read More link in shortened article (snews1.6)
« on: May 21, 2007, 12:10:52 am »

[MOD] ver 1.01 (snews1.6)

This mod will place the 'continue reading' link into the shortened article.
This will also and remove it from the default position in the 'infoline'.

find line in center() that looks like
Quote
file_include(str_replace('[break]','', $text), $shorten);
and change to
Quote
file_include(str_replace('[break]', $rmlink, $text), $shorten);
then paste this line immediately above it.
Quote
if (strlen($r['text']) > $shorten){$rmlink = ' ... <a href="'.db('website').$category.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.l('read_more').'</a>';$shorten=$shorten+strlen($rmlink);}else{$rmlink = '';}
then in file_include()

just after
Quote
$fulltext = substr($text, 0, $shorten);
put all of this...
(this will make sure [break] ends in </p> if there is a <p> in the text... it will also make sure the read more link is before the last </p>)
Quote
/* add any missing </p> and put readmore link in correct spot.*/
   if ($shorten < 9999000 && preg_match('<p>',$fulltext)){
      if(substr_count ($fulltext, '<p>') > substr_count ($fulltext, '</p>')){
         $fulltext .='</p>';
      }elseif(substr_count ($fulltext, '<p>') == substr_count ($fulltext, '</p>')){
         $endp=explode('</p>',$fulltext);$cendp=count($endp)-1;
         $endp[$cendp-1].=$endp[$cendp];$endp[$cendp]='';
         $fulltext=implode('</p>',$endp);
      }
    }
   /* end add missing </p>*/
If this operates as expected, look a bit further down in center() from the file_include line altered above, and locate
Quote
case ($tag == 'readmore'
the next line is
Quote
echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').'</a> '; break;
change to
Quote
/*echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').'</a> ';*/ break;
UPDATE: corrected my posted code... for some daft reason, I'd posted the default comment line instead of readmore line for removal
« Last Edit: August 21, 2007, 09:01:12 pm by Phil Martin »
Logged
Of all the things I have lost, it is my mind that I miss the most.

tarmithius13

  • Sr. Member
  • ****
  • Karma: 7
  • Posts: 469
[MOD]Read More link in shortened article (snews1.6)
« Reply #1 on: May 23, 2007, 06:59:43 pm »

I found an error in this mod.

That last part is wrong. Instead of looking for

Quote
echo $link.$category.'/'.$r['seftitle'].'/#'.l('comment').'1" title="'.l('comments').'">'.l('comments').' ('.$comments_num.') '; break;
you should be replacing the one above it:

Quote
echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').' '; break;
with this:

Quote
/*echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').' ';*/ break;
Your original gets rid of the comments link in the article not the read more one.
Logged
The trick to flying is to throw yourself at the ground and miss.

Free sNews templates HERE

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[MOD]Read More link in shortened article (snews1.6)
« Reply #2 on: May 23, 2007, 10:59:07 pm »

You are, of course, quite correct...

My bad. Post corrected.

thx
Logged
Of all the things I have lost, it is my mind that I miss the most.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD]Read More link in shortened article (snews1.6)
« Reply #3 on: May 24, 2007, 09:58:50 am »

OK, see if I understand this... makes the "read more" INSIDE the shortened article instead of in the info line ??
Logged
"It's only dead fish that goes with the flow... "
Updated

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
[MOD]Read More link in shortened article (snews1.6)
« Reply #4 on: May 24, 2007, 12:10:34 pm »

Thanks philmoz!! Added on my site! :)
Logged

Zucye

  • Sr. Member
  • ****
  • Karma: 5
  • Posts: 347
    • Simplemente una Mujer
[MOD]Read More link in shortened article (snews1.6)
« Reply #5 on: May 24, 2007, 07:11:48 pm »

Quote from: philmoz
change to
Quote
/*echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').' ';*/ break;
Unless I comment the whole line I get a double link to comments when I'm in the Category view (no problem is visible on the home page)
Quote
// case ($tag == 'readmore' && strlen($r['text']) > $shorten):echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').' '; break;
I could be something at my end.  I been changing a lot of things today   :|
Logged
We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). :)

tarmithius13

  • Sr. Member
  • ****
  • Karma: 7
  • Posts: 469
[MOD]Read More link in shortened article (snews1.6)
« Reply #6 on: May 24, 2007, 07:17:31 pm »

You did not see my fix above, I had the exact same issue. Phil did fix it in his original post too.
Logged
The trick to flying is to throw yourself at the ground and miss.

Free sNews templates HERE

Zucye

  • Sr. Member
  • ****
  • Karma: 5
  • Posts: 347
    • Simplemente una Mujer
[MOD]Read More link in shortened article (snews1.6)
« Reply #7 on: May 24, 2007, 07:39:13 pm »

Quote from: tarmithius13
You did not see my fix above, I had the exact same issue. Phil did fix it in his original post too.
Yes I saw it!  That is exactly when I started to had the problem (I had realized yesterday, He had commented the wrong line and I commented the correct whole line like I just posted)
Then Today I saw your post and commented it to just before the "echo" (because I figure you guys know better than me)
Well, like I said, is probably something wrong at my end.  Just though you might want to check. :D
Logged
We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). :)

tarmithius13

  • Sr. Member
  • ****
  • Karma: 7
  • Posts: 469
[MOD]Read More link in shortened article (snews1.6)
« Reply #8 on: May 24, 2007, 08:26:42 pm »

Not sure, it works on my end.
Logged
The trick to flying is to throw yourself at the ground and miss.

Free sNews templates HERE

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[MOD]Read More link in shortened article (snews1.6)
« Reply #9 on: May 24, 2007, 10:46:58 pm »

@ zucye,
your option, I take it, works, so is an alternative.

It is important, in my post that the break; is not commented out to avoid just the issue you posted on...
but, if the whole 'case' is removed, then is not an issue...  :P
Logged
Of all the things I have lost, it is my mind that I miss the most.

Zucye

  • Sr. Member
  • ****
  • Karma: 5
  • Posts: 347
    • Simplemente una Mujer
[MOD]Read More link in shortened article (snews1.6)
« Reply #10 on: May 29, 2007, 07:33:50 am »

I fixed my mess, and now it works perfectly according to your instructions.

Sorry for the confusion. :(
Logged
We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). :)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
[MOD]Read More link in shortened article (snews1.6)
« Reply #11 on: June 04, 2007, 08:59:05 pm »

Thanks phil! This is one for the core... :)
Logged

crm

  • Newbie
  • *
  • Karma: 1
  • Posts: 26
    • planetmayfield.com
Re: [MOD]Read More link in shortened article (snews1.6)
« Reply #12 on: February 04, 2008, 03:53:42 am »

Very nice, thank you, exactly what I needed. Karma +1.
Logged
Endlessly banging my head against the keyboard.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD]Read More link in shortened article (snews1.6)
« Reply #13 on: February 05, 2008, 12:38:08 am »

This mod --I love it, don't think anything else-- has suddenly stopped working for me. I don't know why. I have too many other mods in action to be able to guess at why it's not working. The break works, but it happens a bunch of characters after point of insertion, and the readmore link doesn't get printed.

Among the mods I have running, that are fairly recent additions to the Single User file, are:
Keyword Cloud
Show in front
Links (which isn't working either)
Related articles (which isn't working either)

All of these have worked before, but not when all are together, so it's reasonable to assume some conflict. Maybe some day I'll have time to check with a fresh sNews file...

The mod is great though, in normal settings. ;)
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: [MOD]Read More link in shortened article (snews1.6)
« Reply #14 on: February 05, 2008, 10:24:08 am »

yep, rebuild one at a time, then see which is screwing things up...
Logged
Of all the things I have lost, it is my mind that I miss the most.
Pages: [1] 2