short.ShortStory

Download plugins, language packs and stuff.

Postby Faizan » Tue Dec 16, 2008 7:48 pm

This is an amazing plugin FI-DD. Extremely simple and perfect!
User avatar
Faizan
 
Posts: 55
Joined: Sun Dec 11, 2005 4:26 pm

Postby marcusmagalhaes » Fri Oct 16, 2009 2:39 pm

not working... the image not show .... I want show image, but not count characters..



Ramon wrote:FI-DD.. You might wanna update this plugin to

Code: Select all
<?php
/*
Plugin Name:   Short.ShortStory
Plugin URI:      http://cutenews.ru
Description:   Adds a {tag} to the templates to show n characters of the Short Story.
Version:      1.0
Author:         FI-DD
Author URI:   http://english.cutenews.ru/forum/profile.php?mode=viewprofile&u=2
*/

add_filter('news-entry', 'shortShortStory');
function shortShortStory($output) {
   global $row, $output;
   preg_match('/{sShortStory\|(\d+)}/i', $output, $temp);
      $short_tmp = strip_tags($row['short']);
      $row['short'] = $short_tmp;
   $output = preg_replace('/{sShortStory\|(\d+)}/i', strlen($row['short']) > $temp[1] ? substr($row['short'], 0, $temp[1]).'...' : $row['short'], $output);
   $output = run_filters('news-entry-content', $output);
   return $output;
}

add_filter('template-variables-active', 'shortShortStoryTemplate');
add_filter('template-variables-full', 'shortShortStoryTemplate');
function shortShortStoryTemplate($template) {
   $template['{sShortStory|n}'] = 'Shortens the Short Story to "My short story ..." (n = number of characters)';
   return $template;
}
?>


This way it gets rid of all HTML before counting. So it won't ever screw up your page ;)
marcusmagalhaes
 
Posts: 163
Joined: Tue Apr 24, 2007 1:17 pm

URGENT!!! The solutions not working.....

Postby marcusmagalhaes » Fri Oct 16, 2009 2:45 pm

the short story is even counting the numbers of images link (<img width="70" height="53" border="0" align="left" alt="" style="width: 70px; height: 53px;" src="/XXXX/XXX/XXX/XXX/XXX/ic_camara.gif" />), can we exclude the images link from the count?
marcusmagalhaes
 
Posts: 163
Joined: Tue Apr 24, 2007 1:17 pm

Re: URGENT!!! The solutions not working.....

Postby marcusmagalhaes » Fri Jan 08, 2010 11:56 am

marcusmagalhaes wrote:the short story is even counting the numbers of images link (<img width="70" height="53" border="0" align="left" alt="" style="width: 70px; height: 53px;" src="/XXXX/XXX/XXX/XXX/XXX/ic_camara.gif" />), can we exclude the images link from the count?




the short story is even counting the numbers of images link (<img width="70" height="53" border="0" align="left" alt="" style="width: 70px; height: 53px;" src="/XXXX/XXX/XXX/XXX/XXX/ic_camara.gif" />), can we exclude the images link from the count?
marcusmagalhaes
 
Posts: 163
Joined: Tue Apr 24, 2007 1:17 pm

Postby DarkSlim » Fri Jan 08, 2010 1:16 pm

Hmm try this:

Code: Select all
<?php
/*
Plugin Name:   Short.ShortStory
Plugin URI:      http://cutenews.ru
Description:   Adds a {tag} to the templates to show n characters of the Short Story.
Version:      1.0
Author:         FI-DD
Author URI:   http://english.cutenews.ru/forum/profile.php?mode=viewprofile&u=2
*/

add_filter('news-entry', 'shortShortStory');
function shortShortStory($output) {
      global $row, $output;
      preg_match('/{sShortStory\|(\d+)}/i', $output, $temp);
        $short_tmp = ereg_replace("/<([^<>]*)>/", "",  $row['short']);
      $output = preg_replace('/\<img(.*?)\>/si', '', $output);
      $output = preg_replace('/{sShortStory\|(\d+)}/i', strlen($row['short']) > $temp[1] ? substr($row['short'], 0, $temp[1]).'...' : $row['short'], $output);
      $output = run_filters('news-entry-content', $output);
      return $output;
   }

add_filter('template-variables-active', 'shortShortStoryTemplate');
add_filter('template-variables-full', 'shortShortStoryTemplate');
function shortShortStoryTemplate($template)
{
   $template['{sShortStory|n}'] = 'Shortens the Short Story to "My short story ..." (n = number of characters)';
   return $template;
}
?>


I'm not sure about the syntax so it needs to be tested, there might
be other variations but I can't test it now so if it doesn't work tell me
and I'll try to play with it, hope it'll help

Edit: oops i had a mistake, fixed
Last edited by DarkSlim on Mon Jan 11, 2010 9:25 am, edited 1 time in total.
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby Ramon » Mon Jan 11, 2010 12:19 am

This one will work :)

Code: Select all
<?php
/*
Plugin Name:   Short.ShortStory
Plugin URI:      http://cutenews.ru
Description:   Adds a {tag} to the templates to show n characters of the Short Story.
Version:      1.0
Author:         FI-DD
Author URI:   http://english.cutenews.ru/forum/profile.php?mode=viewprofile&u=2
*/

add_filter('news-entry', 'shortShortStory');

function strip_tags_content($text) {
    $htmlstrip = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text); // Strips the HTML
    $bbstrip = preg_replace('#\[(.*?)\](.*?)\[/(.*?)\]#si', '', $htmlstrip); // Strips BBCode, you need to strip it cause bbcode will turn into html and therefore - if not taken care of - could potentially screw your page up
    return $bbstrip;
}

function shortShortStory($output) {
   global $row, $output;
   preg_match('/{sShortStory\|(\d+)}/i', $output, $temp);
   
      $short_tmp                         = strip_tags_content($row['short']);
      $long                              = strlen($row['short']);
      $short                              = strlen($short_tmp);
      $add                              = $long - $short;
   $temp[1]                           = $temp[1] + $add;

   $output                              = preg_replace('/{sShortStory\|(\d+)}/i', strlen($row['short']) > $temp[1] ? substr($row['short'], 0, $temp[1]).'...' : $row['short'], $output);
   $output                            = run_filters('news-entry-content', $output);
   return $output;
}

add_filter('template-variables-active', 'shortShortStoryTemplate');
add_filter('template-variables-full', 'shortShortStoryTemplate');

function shortShortStoryTemplate($template) {
   $template['{sShortStory|n}']            = 'Shortens the Short Story to "My short story ..." (n = number of characters)';
   return $template;
}

/* NOTE:    Function is still incomplete. {nl} should somehow be accounted for. If you got multiple
         paragraphs you use more space then when you don't. Somehow that should matter, but it does'nt yet.
         
         To make it complete it should count the number of {nl} in $bbstrip and then multiply that amount
         with a - yet to determine - agreeable amount of charactars(depends on the amount of charactars that fit in one line).
         
         That amount needs to be deducted from $temp[1].
         
         LOL the only person who probably understands what i'm saying is FI-DD, so cheers mate :P I can't figure it out
         she is al yours.
*/
?>
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

HELP URGENT!!!

Postby marcusmagalhaes » Wed Feb 17, 2010 3:23 pm

I need put in short-story only image, without text in a section of my site... in my short-story i have a image and text, but when put {sShortStory|n} I want only image...


<img align="left" width="133" height="100" alt="" src="http://www.sinpojud.org.br/UserFiles/Image/%7B894C0979-D601-43E9-B5F3-C65A2609158F%7D_bandeira_do_brasil.bmp" />No dia 21 de outubro as atividades....
marcusmagalhaes
 
Posts: 163
Joined: Tue Apr 24, 2007 1:17 pm

Postby D72 » Wed Feb 17, 2010 8:49 pm

I had the exact same problem a while ago.
You don't have to change any core files in CNR
Just give a class to an element where you don't want to see the images.
Take a look at my site.
http://bit.ly/91ev80
When you scroll down, you'll see a headline with these words in it:

Laatste nieuws: Is e-mail achterhaald in het tijdperk van Twitter, SMS

This is a short line of an article in the news section. The original article has an image in it.
So i made:
Code: Select all
<div class="no_image"><img><p>Your news article...</p></div>

And in your style sheet i did:
Code: Select all
.no_image img{ display:none; }

But be sure you make a unique class. Because you don't want effect something else on the website, right?
It's pretty easy actually.
User avatar
D72
 
Posts: 336
Joined: Thu Feb 22, 2007 12:05 am
Location: NL

Postby Hawk » Fri Feb 19, 2010 7:08 pm

Nice and simple solution there :D smart use of a css :D
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby D72 » Fri Feb 19, 2010 9:30 pm

Hawk wrote:Nice and simple solution there :D smart use of a css :D


:) css is really wonderfull if you know what to do.
with css3 there are many new possibilities. Unfortunately there are some browsers where there is no suport for it yet.
With good css design we even can make tabbed content, accordions, text shadows etc
A while ago these things were only possible with javascripts.
if you understand the basics of css, css can be really simple, smart, lightweight and interactive
User avatar
D72
 
Posts: 336
Joined: Thu Feb 22, 2007 12:05 am
Location: NL

Postby Hawk » Sat Feb 20, 2010 12:40 pm

CSS3 also doesn't pass validation still, which is pity.
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby manu » Thu Apr 01, 2010 8:01 am

Hello,

How I use this plugin ?
I would like do a resume of my news (just the tittle) ; Is it adaptded ?


Regards
manu
 
Posts: 43
Joined: Sun Mar 02, 2008 9:56 pm
Location: France

Postby manu » Fri Apr 02, 2010 12:48 pm

thank you to help me !

I don't know how I can to use this plugin ....
manu
 
Posts: 43
Joined: Sun Mar 02, 2008 9:56 pm
Location: France

Postby DarkSlim » Wed Apr 07, 2010 2:41 pm

manu wrote:thank you to help me !

I don't know how I can to use this plugin ....


You use it like this: {sShortStory|n}

you just change the n to the number of characters you want ot show in the short story,
for example: {sShortStory|70}

Will show your first 70 characters of the short story.
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby manu » Thu Apr 08, 2010 3:55 pm

Thank you ; but I don't uderstand where I write this code.

In a web page html ?

or in a story ?

---
Regards
manu
 
Posts: 43
Joined: Sun Mar 02, 2008 9:56 pm
Location: France

PreviousNext

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests