WordPress.org

Ready to get started?Download WordPress

Forums

HungryFEED
[resolved] How to display other elements from feed (8 posts)

  1. whitsey
    Member
    Posted 2 years ago #

    I am using hungryfeed and it works ok for basic stuff but I am having troubles implementing advanced features. I have read the doco and it doesn't really explain very clearly how to do what I want or if I can do it at all...

    My feed has lots more elements than title, description, date and author... I have about 15 fields in total.

    I've tried adding the field in the template i.e. {{ImageField}} and then tried using {{data['ImageField']}} and then tried using showdata="1" and yet nothing I do will display the image URL.

    I would have thought this would be a basic feature but I cannot seem to find anything anywhere that clearly describes how to implement it?

    Is that because it cannot be done?

    http://wordpress.org/extend/plugins/hungryfeed/

  2. Jason
    Member
    Plugin Author

    Posted 2 years ago #

    Well, hungryfeed makes it easy to access the standard RSS fields but if the feed has extra non-standard fields then you have to use the data array to display them. To be honest it can be tricky to figure out the path because the RSS array structure is so many levels deep including the xml namespaces and everything

    here is an example of a data path to get the the "source" url:

    {{data['child']['']['source'][0]['attribs']['url']}}

    here's an example from iTunes for getting the "price" field of an app:

    data['child']['http://itunes.apple.com/rss']['price']['0']['data']

    you can use show_data="1" (make sure you have the underscore) to have hunryfeed output the raw data array and then you have to do a little detective work to figure out the path to the field that you want.

    hope that helps?

  3. StefanWP
    Member
    Posted 2 years ago #

    I think I've got a similiar problem.

    I want to display a feed from a racing-calendar but the date that shows is one day to early. The date (2011-12-17) come from a field called y:published as you can see on this link from a printscreen of yahoo-pipes but I want to show the correct date which I can see under the label dc:date (2011-12-18T00:00:00+01:00) and also in the html of the feed.

    Could you please help me with this?

    Link to printscreen of yahoo-pipes
    Link to show_data.txt

  4. Jason
    Member
    Plugin Author

    Posted 2 years ago #

    it looks like it could be something like this:

    data['child']['http://purl.org/dc/elements/1.1/']['date'][0]['data']

    unfortunately it's kinda hard to figure out without some experimenting. i'd like to find a better way to handle that but at the moment i'm not sure I have any great solutions for that extra data

  5. StefanWP
    Member
    Posted 2 years ago #

    Great! It worked out just fine!
    Just one more thing. Could you please help me with how to convert the output to not show the timestamp.

    2011-12-18T00:00:00+01:00 -> 2011-12-18

  6. Jason
    Member
    Plugin Author

    Posted 2 years ago #

    Well at the moment HungryFEED doesn't have any capability because it just treats everything like text. but i think there are two options that would work.

    1. add some custom javascript in the HungryFEED settings to look for those dates, parse and re-format them. that wouldn't be too difficult to write for anybody that knows javascript, expecially with jquery.

    2. see if yahoo-pipes offers a feature to process data before it's returned...? I don't know if that's possible but perhaps it's worth investigating?

  7. StefanWP
    Member
    Posted 2 years ago #

    I see.

    I used yahoo-pipes to filter out some special categories and to sort the feed but after stumbled upon your great rss-plugin I'm happy to see it's all done by your plugin!

    I'm no programmer in neither javascript nor php but I thought of a php-function that just trimmed the last part of the string. Maybe it's as easy with javascript but I'm not sure of how to do it. I guess I could put in a php script in the template, surrounding the string I want to change..?

  8. Jason
    Member
    Plugin Author

    Posted 2 years ago #

    the template would be something like this, giving your value a class name so it can be located in the javascript:

    <div class="timeField">{{yourtimefield}}</div>

    then the javascript would be something like this using jquery, you'd have to write the time parsing function, you could probably find somebody on stackexchange to help with that

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    
      $('.timeField').each(function(index)
      {
        var oldTime = $(this).html();
        var newTime = oldTime.split('T')[0]; // (provide your time parsing code here)
        $(this).html(newTime);
      });
    
     });
    </script>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags