Please login or register.

Login with username, password and session length
Advanced search  


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

Author Topic: [micro-mini-MOD] </p> validation on [break] short text  (Read 3071 times)


  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[micro-mini-MOD] </p> validation on [break] short text
« on: May 09, 2007, 12:10:37 pm »

When people plonk a [break] part way through a paragraph (because that is all they want as a leader to the article), the page then fails to validate.

This mod will rectify this problem.

locate file_include() function in snews.php.
grey = original file_include() code.
blue = is what you need to add.
brown = a comment that you can leave in, or remove.
function file_include($text, $shorten) {
   $fulltext = substr($text, 0, $shorten);

if ($shorten < 9999000 && preg_match('<p>',$fulltext)){
// count all start and end tags, provided count of <p> is more, add </p>
   if(substr_count ($fulltext, '<p>') > substr_count ($fulltext, '</p>')){
   $fulltext .='</p>';}}

   $inc = strpos($fulltext, '[/include]');
   if ($inc > 0) {
      $text = str_replace('[include]', '|&|', $fulltext);
note, if the [break] is place inside any other paired elements(<span></span>,<em></em>, etc), it will not fix them up for you.
« Last Edit: November 11, 2008, 04:47:21 pm by Joost »
Of all the things I have lost, it is my mind that I miss the most.


  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [micro-mini-MOD] </p> validation on [break] short text
« Reply #1 on: November 11, 2008, 10:45:20 pm »

(because that is all they want as a leader to the article)

;D ;D ;D

On, Google are using another method for articles.
Everything you write is included inside of only one pair <p></p>
And is working as your mod for article editor.
And formatting is made with <style> .

Not a method for us but in theory, is "bullet proof" for non tech clients ...  because in practice, I saw few blogs with broken style because of bad html code... 
I think we need a "sNews variant" like this for blogging amateurs...
« Last Edit: November 11, 2008, 10:58:50 pm by funlw65 »


  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
Re: [micro-mini-MOD] </p> validation on [break] short text
« Reply #2 on: November 12, 2008, 02:49:35 am »

I forgot to note it earlier... but I added Phimoz's patch (above) to the Official 1.6 Download today as well... and posted a Patch notice on the 1.6 Patches and Fixes Board.  ;)
Do it now... later may not come.
sNews 1.6 MESU | sNews 1.6 MEMU