Results 1 to 5 of 5

Thread: gfeedfetcher substring, need help

  1. #1
    Join Date
    Aug 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default gfeedfetcher substring, need help

    Hello all,

    I use the gAjax RSS Feeds Displayer v2.0 (http://www.dynamicdrive.com/dynamici...sdisplayer.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/dynamici...feedfetcher.js

    HTML:

    Code:
    <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>
    Last edited by jscheuer1; 08-17-2013 at 10:04 PM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by hofleverancier; 08-18-2013 at 06:22 PM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    For that, css style seems like it might be the best approach, add this to the stylesheet:

    Code:
    #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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by hofleverancier; 08-18-2013 at 06:22 PM.

Similar Threads

  1. I need gfeedfetcher help
    By pappa74 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-06-2013, 08:49 PM
  2. gfeedfetcher issue
    By gendos in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 07-17-2012, 03:53 PM
  3. gfeedfetcher problem
    By takethecake in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-19-2012, 02:35 AM
  4. gfeedfetcher tweak
    By agoulet in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 11-20-2011, 03:37 PM
  5. Help with indexOf() and substring()
    By craigtb in forum Java
    Replies: 6
    Last Post: 02-08-2007, 09:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •