SimplePortal

Customization => Blocks and Modifications => Topic started by: ccbtimewiz on May 19, 2009, 05:17:22 PM

Title: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on May 19, 2009, 05:17:22 PM
Performing this edit will allow you, on Simple Portal, to define where the article should stop showing and proceed with a <view more> link.

This will render the character count cut-off useless unless you forget to define a cut-off.

SP version 2.2.1

Open ./SPortal2.php

Find:
Code: [Select]
$all_link = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
}

Replace with:
Code: [Select]
$all_link = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
}

// If you find "" if the body, then process this...
if (preg_match('/\/i', $row['body']))
{
// First, count each character in the body, and then locate when  occurs.
$cutoff = strrpos(un_htmlspecialchars($row['body']), '');

// Now, fix the article by only showing the text that was counted before  occured.
$fixed_article = $smcFunc['substr']($row['body'], 0, $cutoff);

// And now, assign the article as the fixed article.
$row['body'] = $fixed_article;

// The "click here for more" link.
$row['body'] .= '...
<br /><a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">(view full article)</a>';
}

Open ./Sources/Subs-SPortal2.php

Find:
Code: [Select]
if ((SMF == 'SSI' && empty($context['standalone'])) || empty($context['template_layers']) || WIRELESS || $initialized)
return $tourniquet;

Replace with:
Code: [Select]
if ((SMF == 'SSI' && empty($context['standalone'])) || empty($context['template_layers']) || WIRELESS || $initialized)
return $tourniquet;

$tourniquet = str_replace('', '', $tourniquet);

After doing these edits, you can define, in a post, the tag: . If said post is an article, the article will stop showing and proceed with a "view more" link where to define said  tag.

 will appear invisible to users-- so you can define it without worry.
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: Nathaniel on May 19, 2009, 06:06:14 PM
Moved to the Blocks and Modifications board.

Looks good. :)
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: konkaen on July 08, 2009, 04:37:45 PM
Is it possible to implant this into SMF 1.1.9 as i have no SPortal2.php but i have SPortal1-1.php
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on July 08, 2009, 07:11:31 PM
Never tried it, but it should work if it has a similar code structure.
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: H on July 08, 2009, 07:41:58 PM
Why not just upgrade to a newer Simpleportal?
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: konkaen on July 09, 2009, 11:20:53 AM
Why not just upgrade to a newer Simpleportal?

Won't work, we dont want ( YET ) to update to SMF 2 rc1 - we dont like beta's and that kind of stuff ;)


And to above H, nope, it gives all kind of weird errors...
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: H on July 09, 2009, 11:49:30 AM
Simpleportal 2 will run on SMF 1.1.x :)
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: konkaen on July 09, 2009, 03:30:15 PM
Simpleportal 2 will run on SMF 1.1.x :)

I Know but we dont have the SPortal2.php and Sub-Portal for that matter we have 1...

(http://lorddusk.netii.net/screenshots/2009-07-09_212929.png)

Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on July 18, 2009, 01:23:23 PM
Konkaen, were you able to get my trick to work?
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: smldmr on July 31, 2009, 02:52:37 PM
hello in SPortal2.php i cant fint the

Code: [Select]
$all_link = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
}

code. What is wrong here?
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on July 31, 2009, 02:57:32 PM
Attach the file please.
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: smldmr on July 31, 2009, 03:17:23 PM
here it is.
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on July 31, 2009, 03:33:10 PM
This might do it;

Find:
Code: [Select]
if (!empty($modSettings['articlelength']) && $smcFunc['strlen']($row['body']) > $modSettings['articlelength'])
$row['body'] = parse_bbc(sp_truncateText($row['body']), $row['smileys_enabled'], $row['id_message']) . '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
else
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_message']);

Replace with:
Code: [Select]
if (!empty($modSettings['articlelength']) && $smcFunc['strlen']($row['body']) > $modSettings['articlelength'])
$row['body'] = parse_bbc(sp_truncateText($row['body']), $row['smileys_enabled'], $row['id_message']) . '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
else
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_message']);

   // If you find "" if the body, then process this...
   if (preg_match('/\/i', $row['body']))
   {
      // First, count each character in the body, and then locate when  occurs.
      $cutoff = strrpos(un_htmlspecialchars($row['body']), '');

      // Now, fix the article by only showing the text that was counted before  occured.
      $fixed_article = $smcFunc['substr']($row['body'], 0, $cutoff);

      // And now, assign the article as the fixed article.
      $row['body'] = $fixed_article;

      // The "click here for more" link.
      $row['body'] .= '...
         <br /><a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">(view full article)</a>';
}
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: smldmr on July 31, 2009, 04:32:24 PM
thanks for your help, now it funtcioning. But there is a little problem now.

The place of cutoff is not the same place where i write the cutoff tag. The cut place is 14-15 characters longer.
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: ccbtimewiz on July 31, 2009, 04:33:57 PM
I'll have to look into it as the new SP version apparently broke the cutoff code.

I'll get back to you. :)
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: MactasticMendez on January 12, 2010, 11:50:09 AM
hey i was wondering if there is any news on getting the  working again as no matter how long i let the article length be without it been ridiculously long it seems to cut off the article part way through a word or through a sentence.

thanks
Robin
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: BPLive on January 25, 2010, 02:26:27 AM
hey i was wondering if there is any news on getting the  working again as no matter how long i let the article length be without it been ridiculously long it seems to cut off the article part way through a word or through a sentence.

thanks
Robin

I agree... this is a huge function that should be incoporated in SP.    :nervous-happy:
Title: Re: Cut off articles using a custom [cutoff] tag.
Post by: Dziaga on December 05, 2011, 03:52:53 PM
I can't find  SPortal.php in /Sources  :(
I have only  Subs-Portal.php, this is it?   
SimplePortal 2.3.8 © 2008-2024, SimplePortal