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.

Author Topic: [micro-MOD] Add a jump anchor for the [break]  (Read 2516 times)

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 131
  • Posts: 2798
[micro-MOD] Add a jump anchor for the [break]
« on: January 31, 2009, 05:29:54 PM »

As mods go, I don't think there's any smaller than this one. But I find it useful, so perhaps others will too.

MOD PURPOSE: Add a "jump" anchor to the [break] function

MOD REASON: So that when [break] is used in a long-ish article, clicking the Read More link will take you to the full article's [break] point and not force you to read the full article all over again (because you've already read the article up until the [break] point, right?)

MOD DEMO: For those of you who use any browser other than IE -- that is Firefox, Safari, Google Chrome, Omniweb, Flock, Konqueror, Opera, Shiira, yada yada yada... -- go to my site and look for the first article that is broken up -- the 2 first are not -- then click the "Continue" button. But the easiest way, since this is such a small mod, is to try it yourself (preferably on a test site before running it live). Don't forget to backup your files first though.

MOD REQUIREMENTS:  Tested in sNews 1.7 latest release version. However, this will work in any version of sNews that has the [break] function, although you might need to adjust it slightly depending on sNews version and whatever other changes you've made that I'm not aware of.

THE MOD

0. Backup your files.
1. In snews.php, function articles(), find the following line:

Code: [Select]
file_include(str_replace('[break]', '',str_replace('&', '&', $text)), $shorten);
2. Change it to this:

Quote
file_include(str_replace('[break]', '<a id="jump"></a>',str_replace('&', '&amp;', $text)), $shorten);

3. In the "if($infoline ...) switch, find this case:

Code: [Select]
case ($tag == 'readmore' && strlen($r['text']) > $shorten):
echo $link.$uri.'/'.$r['asef'].'/">'.l('read_more').'</a> ';
break;

And change it to this:

Quote
case ($tag == 'readmore' && strlen($r['text']) > $shorten):
echo $link.$uri.'/'.$r['asef'].'/#jump">'.l('read_more').'</a> ';
break;

END MOD

Yes, that is all you need. Now, all your broken articles will get the "jump" anchor. No more reding half the article twice! ;)

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 947
    • cssanarchy.com
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #1 on: February 01, 2009, 05:42:12 AM »

Hey Freed nice to see you again :)..One questions...Whay you hate so much IE? I see you post link to download OPERA broswer like better one but Opera has problems with java script code.Also you lose lot of visitor who use IE too.Personal i hate safari broswer but i doo design for safari.Its not design for broswer its design for people who use same.We all need to make our designs for people not for broswers.....
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 ♥

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 131
  • Posts: 2798
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #2 on: February 01, 2009, 06:19:58 AM »

Sasha, I don't *hate* IE. The issue I have with IE is that it does not support accepted web standards in a good way. Even in an acceptable way. And *for my personal sites* I don't intend to add a lot of hacks and conditional comments to make my sites work for IE 6 and 7.
*For non-personal sites*, e.g sites that I build for others, it is the choices of the site owner that governs how the site is built. If they want a site that works in IE6/7, they will get that. But my own, personal, sites? No. And excluding IE completely is a much simpler way of doing it than letting them in, serving content that will appear odd or off to them, and have them contact me about things that "aren't working" when it's actually the browser they use that is causing them problems (unless of course I F*** up somewhere, which is known to happen occasionally ;)). It is a personal choice. And it doesn't affect very many people, I have stats to prove that -- every site I've run has had an overwhelmingly large share of Safari and Firefox visitors. I don't really care much why that is, I just see that it is so. The stats prove that IE users *on my personal sites* aren't numerous enogh to be a factor. If they were, I might consider rethinking. But most likely not. Besides, if IE6 isn't prevented from accessing sites, how can we ever get people to stop using it (lots of security flaws, old rendering engine, very little support for accepted standards, requires hacks galore...)

If someone likes IE6 over other browsers, that's fine by me, I have no opinion about that. But why should that person force me to do a number of unnecessary additions to my sites, just to satisfy that one browser?

My personal sites will work *the same way* in a number of *standards compliant* browsers. You mention Opera which is interesting since Opera has about 0.4% of the browser market as a whole and doesn't even show up in my statistics. But *it does support web standards to a fairly great extent*, Opera 9 was one of the first browsers that passed the Acid2 test. So, Opera I have no problem with even if it may have some issues with javascript (and type rendering, and maybe a few other details that I'm not aware of).

In summary: I don't hate IE. I dislike it, but I don't hate it. I build my sites according to web standards which make them look and work the same in all standards compliant browsers. If a browser is not sufficiently standards compiant, I have no reason to add support for it. And that applies only to my personal, non-business, sites. And, this has absolutely nothing to do with the presented mod. But it's nice to see you too. ;)

Sven

  • Dev Invitee
  • ULTIMATE member
  • *****
  • Karma: 88
  • Posts: 2069
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #3 on: February 03, 2009, 08:06:07 AM »

1 K for Mr Smith. hip hip.... hurra!

mdj

  • sNews Dude
  • Full Member
  • *****
  • Karma: 44
  • Posts: 226
    • mdj.us
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #4 on: February 04, 2009, 06:28:43 PM »

All browsers have issues, FF 2 and under and it's inline-block issues have caused me no end of headaches, however I have to agree that IE is generally the worst of the bunch. IE 7 is tolerable, but IE6 is just horrible, I've stopped bothering to code for IE6.

Anyways, nice little hack there Fred, I almost did something similar, I was going to have the anchor at the top of the article so they could scan down as I put my intro breaks around the 2 paragraph usually, but I ended up not implementing anything. If I wrote long articles with big chunks before the break like that, I would definitely use this.

Fred K

  • sNews Dude
  • ULTIMATE member
  • *****
  • Karma: 131
  • Posts: 2798
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #5 on: February 04, 2009, 07:52:02 PM »

Thanks Matt. +1 on FF-older and inline-block (Safari 2 and down had the same problem, but I think FF, Opera and Safari users *in general* are quicker to update their browsers to the latest version. Could be wrong though. FF3 and Safari 3 have no issues with inline-block. Great property, that.)

Ideally I would have liked to have the jump anchor a couple-three lines above the [break], but the mod works well enough as is. And it does depend on the length of the articles, whether to implement it or not. If most of your articles are a screen and a half long, it's worth considering imho.

@Sven: Merci, merci! Vous etes trop gentile. ;) (is that gentile with or without the e, I never remember which, lol)

Sven

  • Dev Invitee
  • ULTIMATE member
  • *****
  • Karma: 88
  • Posts: 2069
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [micro-MOD] Add a jump anchor for the [break]
« Reply #6 on: February 06, 2009, 08:34:15 AM »

Gentil, Mr Smith. Idiot but gentil. ;D