Author Topic: [Simple Portal] Cut off articles using a custom [cutoff] tag.  (Read 1942 times)

0 Members and 1 Guest are viewing this topic.

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
I just recently modded this for a friend, and I decided I should share this with everyone.

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.

SMF 2.0

--> SP version 2.1.1

* Open ./Sources/SPortal.php

Find:
:
if ($cutoff !== false)
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);

$row['body'] .= '...';
}

Replace with:
:
if ($cutoff !== false)
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);

$row['body'] .= '...';
}

// 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.php

Find:
:
// Inside these tags autolink is not recommendable.
$no_autolink_tags = array(
'url',
'iurl',
'ftp',
'email',
);

Replace with:
:
// Inside these tags autolink is not recommendable.
$no_autolink_tags = array(
'url',
'iurl',
'ftp',
'email',
);

# @ccbtimewiz
// Edit for Simple Portal's article <more> link.
$codes[] = array(
'tag' => 'cutoff',
'type' => 'closed',
'content' => '<!-- // -->',
);

Find:
:
$empty_tags = array('br', 'hr');
Replace with:
:
$empty_tags = array('br', 'hr', 'cutoff');


--> SP version 2.2.1

Open ./SPortal2.php

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

Replace with:
:
$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:
:
if ((SMF == 'SSI' && empty($context['standalone'])) || empty($context['template_layers']) || WIRELESS || $initialized)
return $tourniquet;

Replace with:
:
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.
« Last Edit: May 19, 2009, 05:19:03 PM by ccbtimewiz »

Offline Smoky

  • who, me?
  • Guru
  • *
  • Posts: 3980
  • Karma: 1450
  • Gender: Female
  • It's all in your HEAD!
    • HangOutSpot
  • SMF Version: 2.0 ??
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #1 on: March 12, 2009, 04:37:10 PM »
neat CCB  :dnc :vic   thanks! ;)
Oh wow, guess who dropped by! Im still on secondlife.. but will respond to im's *waves

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13222
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #2 on: March 16, 2009, 06:48:00 AM »
Another great trick from ccb. ;)

Offline fotografo74

  • New Member
  • *
  • Posts: 4
  • Karma: 138
  • Gender: Male
  • SMF Version: 2 RC1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #3 on: March 31, 2009, 12:06:16 PM »
Thanks for this tips :-)
I posted to simpleportal.net this question http://simpleportal.net/index.php?topic=1630.0 and LHVWB has addressed me in this forum :-)  ( sorry for my english)
I modified Subs.php e SPortal2.php ( i use SP 2.1.1 and SMF2 RC1)..not errors but the link View more not appears... :cry
My forum : www.macroforum.org
I attached Subs.php and SPortal2.php
Thanks in advance for any help...
aNtonio

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #4 on: March 31, 2009, 02:20:22 PM »
Are you placing the tag  in your article-like posts?

Offline fotografo74

  • New Member
  • *
  • Posts: 4
  • Karma: 138
  • Gender: Male
  • SMF Version: 2 RC1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #5 on: March 31, 2009, 04:58:39 PM »
Are you placing the tag  in your article-like posts?
No......now i placed the tag...and works! thanks!!!  :)
Antonio

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #6 on: March 31, 2009, 05:26:46 PM »
Glad to see you got it. :)

Yeah, I should put better instructions The way I coded it, it searches the article for the tag . Together with the edits I put for Subs.php,  doesn't actually show up in the post as it parses no content. All it really does is tell my code in SPortal.php or SPortal2.php (depending on what version of SMF you're running) to stop processing the article after it finds that tag, and then breaks a couple times in HTML and produces that "read more" link.

At the moment, if you forgot to define a  tag, the article will load by your current SP preferences.

Offline fotografo74

  • New Member
  • *
  • Posts: 4
  • Karma: 138
  • Gender: Male
  • SMF Version: 2 RC1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #7 on: April 01, 2009, 04:56:22 AM »
Glad to see you got it. :)

Yeah, I should put better instructions The way I coded it, it searches the article for the tag . Together with the edits I put for Subs.php,  doesn't actually show up in the post as it parses no content. All it really does is tell my code in SPortal.php or SPortal2.php (depending on what version of SMF you're running) to stop processing the article after it finds that tag, and then breaks a couple times in HTML and produces that "read more" link.

At the moment, if you forgot to define a  tag, the article will load by your current SP preferences.
Ok...thanks!  :)
Last question: it's not possibile to apply this modify to news board block?
I have in my home page 3 news board block and others articles/post ( where i applied è cutoff ] tag )
In board news blocks this modify not works...it's hard modfiy the board news block code ?
Thanks!
Antonio

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #8 on: April 01, 2009, 09:48:46 AM »
Certainly, but I'm not sure which you're talking about.

Could you perhaps show me your site and what exactly you'd like to cut off?

Offline fotografo74

  • New Member
  • *
  • Posts: 4
  • Karma: 138
  • Gender: Male
  • SMF Version: 2 RC1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #9 on: April 01, 2009, 11:30:03 AM »
Certainly, but I'm not sure which you're talking about.

Could you perhaps show me your site and what exactly you'd like to cut off?

Thanks for helps :-)
My forum is www.macroforum.org
You see the last two articles,for example?( Nuova sezione fotografica: Fotomicrografia and Logo e banner RSS....above the SMF copyright)
This articles are not created by Make article in topic view, but are extract from Annunci importanti board (SP board news block)
In this articles tag cutoff not works.
It's possible make this?
thanks...and sorry for my english!
antonio
« Last Edit: April 02, 2009, 02:30:13 AM by fotografo74 »

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #10 on: May 19, 2009, 05:19:20 PM »
Updated for the new SP version (2.2.1).

Offline bluesinjid

  • New Member
  • *
  • Posts: 3
  • Karma: 29
  • Gender: Male
    • Modernopolis
  • SMF Version: 2.0 RC1-1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #11 on: July 03, 2009, 05:44:12 PM »
Hi, sorry if it works already but does this work for version 2.2.2 of simpleportal?
Simcity 4

FireFox

Simcity 4 And Cities XL Fans Unite!

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #12 on: July 03, 2009, 05:59:16 PM »
It does.

Offline Chit-Chat ChatterBox Boss

  • Sr. Member
  • *
  • Posts: 314
  • Karma: 741
  • Gender: Male
  • SMF Helper's noob helper...I mean friendly helper!
    • Chit-Chat ChatterBox
  • SMF Version: 2.0 RC1-1
Re: [Simple Portal] Cut off articles using a custom [cutoff] tag.
« Reply #13 on: July 03, 2009, 06:17:16 PM »
Great add CCB + Rep!