 |
 |
 |
 |
 |
| Author |
Message |
rats
Joined: 29 May 2006 Posts: 44
|
|
Parse/Strip HTML Tags |
|
It would be nice if someone can make a parsing script that removes the html tags within the template, like [parse]...[/parse] 
|
|
| Fri Sep 07, 2007 5:33 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
rats
Joined: 29 May 2006 Posts: 44
|
|
|
|
sorry for the double post, but I'm not the kind of man who ask for something and hopes to have it by tomorrow at afternoon, and I did something really neat, but not the way I wanted.
I've managed to make a strip tag but you won't be able to use it on other tags (like [parse]{sShortStory|300}[/parse] which was my main goal) but you can still use it in a very n00bish way until someone puts it in a plugin and make a truncate function with it. So:
Open show.news.php in cutenews/inc/
Find
 |  | $output = str_replace('{id}', $row['id'], $output); |
Add above
 |  | $strip = run_filters('news-entry-content', $row['short']);
$strip = ereg_replace("<[^>]*>","",$strip);
$strip = ereg_replace("\[[^>]*\]","",$strip);
// $strip = substr($strip, 0, 90); |
Find
 |  | $output = str_replace('{alternating}', $alternating, $output); |
Add below
 |  | $output = str_replace('{strip}', $strip, $output); |
Use the {strip} tag in your template to echo the short-story (!!!) with no html AND QUICKTAGS.
Some explaining:
I've "stoled" the replacement function from the BadDog's MySQL Search... that's the
 |  | $strip = ereg_replace("<[^>]*>","",$strip); |
Next I've redone it to strip the QuickTags here:
 |  | $strip = ereg_replace("\[[^>]*\]","",$strip); |
IF YOU WANT TO TRUNCATE THE CODE LIKE sShortStory PLUGIN FROM FI-DD (but much gayer)
Change
 |  | // $strip = substr($strip, 0, 90); |
to
 |  | $strip = substr($strip, 0, 90); |
and change "90" to your desired number of characters.
I hope someone will pick what I've done here and port it lie Fi-dd's sShortStory plogin so we'll be able to use {strip|90} or something
Cheers
|
|
| Fri Sep 07, 2007 6:32 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
Just add the stripping part to the plugin...
Open plugins/shortShortStory.php and find this:
 |  | preg_match('/{sShortStory\|(\d+)}/i', $output, $temp); |
add below:
 |  | $row['short'] = ereg_replace("<[^>]*>","",$row['short']);
$row['short'] = ereg_replace("\[[^>]*\]","",$row['short']); |
|
|
| Mon Sep 10, 2007 5:49 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|