Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: RSS Display Box and adding copyright to output file

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default RSS Display Box and adding copyright to output file

    RSS Display Box

    http://www.dynamicdrive.com/dynamici...ybox/index.htm

    http://web-user.net/rss/grail3.html

    http://web-user.net/rss/rssbox/outputbody.php

    I have been trying to add one thing to my feeds,copyright ,info.Every attemp has failed.I have read the simplepie sites info and have been unable to get it to show this information.

    This is the output page.http://web-user.net/rss/rssbox/outputbody.php

    Could someone help me out before I implode-lol

    Also, a quick question.Is there any sample templates for people to look at to get an idea as to what we can do with this script?

    I really like this script and am working on redoing the site design to make it more unique.http://web-user.net/rss/grail3.html

    Thanks, in advance for the help.

    Bud

  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

    First of all, I don't know if this is your intention, but you cannot copyright material from a feed other than your own. It's already copyright by them or from the source from which they got it. Unless they require a notice to that effect, you need not bother supplying it. A single statement on the 'top' page that all material is copyright its respective copyright holders is sufficient.

    Second, the error is on web-user.net/rss/rssbox/outputbody.php. Since it's parsed by the server before we get to see it, we cannot see or fix its PHP code unless you make a copy of that file as outputbody.txt and provide a link to it. If it has any included code, we may need to see that in text form as well.
    - John
    ________________________

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

  3. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default not what I mean

    I am trying to get the output copyright from the feed for the source of the feed.Not to copyright the feed for myself.

    http://web-user.net/rss/rssbox/outputbody.txt

    I tried this and then removed the line
    <div class="rsscopyright"><?php echo $feed->get_copyright(); ?></div>

    which did not work.

    I have tried a few different versions but nothing works.

    Thanks,
    Bud
    Last edited by ajfmrf; 01-10-2011 at 12:57 AM. Reason: adding a comment-I want to get more then the output I am getting and just choose the copryright.

  4. #4
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default wish to get more from the feed

    Such as the date , time and publisher.

    I do not see any place that gives information as to how to add to the template to get any more info from the feeds.

    I am real new to this so I hope you don't get annoyed with my questions.

    Thanks,
    Bud

  5. #5
    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

    If I'm annoyed, it's not with you. My tone may have suggested that. If it did I apologize. I was trying to clarify things by making that statement and asking that question. By responding as you did and supplying the text version of the file you have helped clear things up for me. Thank You.

    Looking at the file in text form, it's obviously an indirect include for simplepie.inc which has things like:

    Code:
    get_title()
    get_description()
    etc. defined for any given item. get_copyright() is not defined for the feed, and the feed ($feed) is not passed to outputbody.php anyway. There is a get_feed_copyright() defined for the feed though.

    Now, I don't know a whole lot more about PHP than you do, but some. And I do understand scripted languages in general fairly well.

    I found that by editing outputbody.php to include the highlighted:

    Code:
    <?php
    //Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com
    //For syntax pf bpdu, see: http://simplepie.org/docs/installation/from-scratch/ and http://simplepie.org/docs/reference/
    //Function by default defines 3 different body outputs (templates). Modify or add additional templates as desired
    
    
    function outputbody($item, $template="", $feed){
    if ($template=="" || $template=="default"){ //DEFAULT TEMPLATE
    	?>
    	<DIV class="rsscontainer">
    	<div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></div>
    	<div class="rssdate"><?php echo $item->get_date('d M Y g:i a'); ?></div>
    	<div class="rssdescription"><?php echo $item->get_description(); ?></div>
    	<div class="rsscopy"><?php echo $feed->get_feed_copyright(); ?></div>
    	</DIV>
    	<?php
    } //end default template
    else if ($template=="titles"){ //"TITLE . . .
    And by editing main.php in the same folder around line #40 (near the end) to include the highlighted:

    Code:
    function outputitems(){
    global $feed, $feednumber, $templatename;
    $max = $feed->get_item_quantity($feednumber);
    for ($x = 0; $x < $max; $x++){
    $item = $feed->get_item($x);
    outputbody($item, $templatename, $feed); //call custom outputbody() function
    }
    }
    It worked for the demo's NYT feed and caused no error for those feeds that had no copyright data.

    It did however attach the copyright info to each item, rather than just once at the end of the feed. Doing the latter is possible, I'm just not sure of the best way to go about it at the moment.
    - John
    ________________________

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

  6. #6
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default Thanks John

    I will try the code adjustments you posted.

    I did not mean to imply you were annoyed John.I apologize for making you feel as if you came across that way.

    I have found in the past when I go and ask a question once or twice in a forum that I ,being a novice , sometimes ask too many questions and get a negative response so I just try to break the ice so to speak and make sure I am not annoying anyone lol

    Sometimes an answer is right in front of me but I can't see it because I am so focused on getting something to work that I miss a teeny,tiny thing and thats annoying to me-lol

    I do appreciate your help John and if I can ever help you ,just holler at me.

    Thanks,

    Bud

  7. #7
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    You are completely right John .

    I worked as you described.

    I tried to get a couple of other "things" and got errors again.

    I will keep trying and I am sure due to your help at some point I will figure it out.

    You would think it would all follow the same wording just changing what you want to get from the feeds but I am not getting it so far.

    I find that I always have to go the hard,long way to get things to work.Nothing ever comes easy-lol

    Bud

    ps-I was hoping getting one thing to work would directly lead to adding/changing more but so far just the one has worked-
    Last edited by ajfmrf; 01-11-2011 at 02:16 AM. Reason: add

  8. #8
    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

    This may not help, but does explain things a bit:

    I was looking at these files some more and now see more of what's happening. The central file in a sense is main.php. It includes (requires actually - a more imperative form of the include directive) outputbody.php and simplepie.inc. So all of the functions on simplepie.inc are available to outputbody.php. However, since outputbody.php has a function on it, outputbody() which is called from main.php, only those objects that are passed to that function may be worked with. That's why I had to pass it the $feed object to get the feed function for copyright to work and to have something to work with.

    The docs for simplepie are here:

    http://simplepie.org/wiki/reference/start

    But those are probably not completely accurate because simplepie has been updated since the version used with this script. They will give you some ideas.

    There are also simplepie forums, FAQs and how to material, all available at or with their addresses listed on:

    http://tech.groups.yahoo.com/group/simplepie-support/

    But by just looking at the code in simplepie.inc you should be able to see what's available. If you want to run something in there for outpubody and are having trouble doing so or doing so in the way you want to, let me know. If you want something that's not in there though, we would have to make a custom function for it. I may or may not be able to help with that.
    - John
    ________________________

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

  9. #9
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default hmmm

    So if I find something I would like to experiment with,how do I figure out if it will work with the "feed" part you had me add?Is there a way to figure it out or do I have to try and code it?I try to use the "item" already there with what I find at simplepie and nothing worked but what you did.

    I must sound kinda dumb by now,lol

    It is quite confusing on my part so far.I test things by trial and error and always get "error"........

    I will try more tomorrow.

    Have a great evening John.

    Thanks for the help.

    Bud

  10. #10
    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

    Well simplepie is organized into sections. There's one section that creates some objects when main.php does:

    PHP Code:
    $feed = new SimplePie(); 
    These objects then all become properties of $feed for that feed.

    The SimplePie() function itself is so complex that perhaps not all of its objects become accessible objects of $feed for that feed, but a lot of them do.

    The main.php file uses this fact to get the items when it later does:

    PHP Code:
    <?php . . . 
    function 
    outputitems(){
    global 
    $feed$feednumber$templatename;
    $max $feed->get_item_quantity($feednumber);
    for (
    $x 0$x $max$x++){
    $item $feed->get_item($x);
    outputbody($item$templatename$feed); //call custom outputbody() function
    }
    }

    ?>

    <?php
    if ($feed->data){
    outputitems();
    }

    ?>
    I simply passed along the $feed so I could use its:

    PHP Code:
        function get_feed_copyright()
        {
            if (!empty(
    $this->data['info']['copyright']))
            {
                return 
    $this->data['info']['copyright'];
            }
            else
            {
                return 
    false;
            }
        } 
    to get the copyright info in outputbody.

    There are a lot of these functions you can use in simplepie. Do a search on simplepie.inc for:

    function get_feed_
    to turn up six I'm sure you can use. These are all in the init() function of the SimplePie() function and should be available to $feed on outbody in our current modified version as should their neighbors in that section. However the ones that aren't get_feed_something might not be all that useful and might cause problems.

    On to the functions that can be used with $item. These are all in the section:

    Code:
    class SimplePie_Item
    Those which aren't get_something might not be all that useful and might cause problems.

    It's likely that in either of these sections we could add get functions if we know the structure of the feed or item well enough to write our get function to look in the right place in the $feed or $item objects respectively. That in combination with following the template of the other get functions should allow us to do this. If we do that correctly and a given feed or item has that information, we can make outputbody use that function to output that information following the template on outbody.php already established with:

    PHP Code:
    <?php echo $item->get_title(); ?>
    for items and now:

    PHP Code:
    <?php echo $feed->get_feed_copyright(); ?>
    for the feed.

    The bottom line though is that we cannot use what isn't there in the simplepie.inc file. Even if it is there, we need to be careful what we do with it if it isn't just a get for fear of messing up the item or the feed in mid parse by outputbody. And, as I say, not all functions are available to all objects, just the ones that were created for those objects in simplepie.inc
    Last edited by jscheuer1; 01-14-2011 at 04:27 AM. Reason: English usage
    - John
    ________________________

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

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
  •