PDA

View Full Version : gfeedfetcher substring, need help



hofleverancier
08-17-2013, 09:51 PM
Hello all,

I use the gAjax RSS Feeds Displayer v2.0 (http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm). How can is shorten a line of text. (substring) I only want to show for example the first 25 letters of a feed. What do i need to do?
Need your help, thanks.

Best regards, Dan

Code i use:
gfeedfetcher.js : http://www.dynamicdrive.com/dynamicindex18/gfeedfetcher.js

HTML:


<script type="text/javascript">

var cssfeed=new gfeedfetcher("example1", "example1class", "")
cssfeed.addFeed("CSS Drive", "http://www.cssdrive.com/index.php/news/rss_2.0/") //Specify "label" plus URL to RSS feed
cssfeed.displayoptions("date") //show the specified additional fields
cssfeed.setentrycontainer("li") //Display each entry as a list (li element)
cssfeed.filterfeed(10, "title") //Show 10 entries, sort by date
cssfeed.init() //Always call this last

</script>

jscheuer1
08-17-2013, 11:02 PM
In the example feed from your post, it's only showing the title and date. In most cases that will not be over 25 characters. The script does allow for one or more regular expressions to be applied to the each of the content fields used. The possible fields are title (always shown), date, time, datetime, label, snippet, description. If you were showing the description, that (regular expression(s)) could be used to limit it. Even if you're just showing title and date, it could be used to limit the length of the title. The title is usually linked though, so it would be a little tricky to shorten just the text of the title without losing the link. But, one way or the other, it could be done. What you might want to show are just the title and snippet. Those might not always be 25 characters or less, but usually would be relatively short compared to the full description. Or, as you have it in your post, just title and date, that's always going to be pretty short.

For more information see:

instance.displayoptions

and:

instance.addregexp

In the table gfeedfetcher object and methods on the demo page.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

hofleverancier
08-17-2013, 11:27 PM
Hello John,

Thanks for your reply, i want to shorten it, so every rss feed tiltle fits in one line in the box.
Hope somebody can help me out.


Best Regards,

Dan

jscheuer1
08-18-2013, 02:07 AM
For that, css style seems like it might be the best approach, add this to the stylesheet:


#example1 li .titlefield {
width: 117px;
overflow: hidden;
display: inline-block;
white-space: nowrap;
}

The browser cache may need to be cleared and/or the page refreshed to see changes.

hofleverancier
08-18-2013, 10:09 AM
Hello John, thanks again for your reply and solution, i used the css and changed it a bit.
I had to change the span class of the labelfield in the gfeedfetcher.js into <div id="labelfield"> to align the label. But iam sathisfied. Thanks again!

Best Regards,

Dan