Display rss feeds (with date) from outside coppermine? Display rss feeds (with date) from outside coppermine?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Display rss feeds (with date) from outside coppermine?

Started by fran86, June 08, 2015, 07:18:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fran86

I hope I am in the right place to post this.

Is it possible to have rss feeds (with date) from outside coppermine? such as wordpress latest posts rss in footer or sidebar of my gallery. Hopefully without a plugin. All my searches seem to find is coppermine rss feed or coppermine feed in wordpress.

phill104

There are plugins available such as this one - http://forum.coppermine-gallery.net/index.php/topic,62764.0.html but currently RSS is not supported out of the box. You could manually code it but the plugin should do the job fine.
It is a mistake to think you can solve any major problems just with potatoes.

fran86

Quote from: Phill Luckhurst on June 08, 2015, 11:30:07 AM
There are plugins available such as this one - http://forum.coppermine-gallery.net/index.php/topic,62764.0.html but currently RSS is not supported out of the box. You could manually code it but the plugin should do the job fine.

Thank you for your reply but that plugin isn't what I am looking for. I'd like to add my wordpress news feed to coppermine, correct me if I didn't understand the description there. :/

phill104

You could use the anycontent.php facility Coppermine has. It allows you to add your own code to your coppermine page.

http://documentation.coppermine-gallery.net/en/php-content.htm

Your code could be something like (edit line 3 to reflect your own feed. Edit line 14 to set the amount of articles to display.)

[/<?php
2.
$rss = new DOMDocument();
3. $rss->load('http://wordpress.org/news/feed/');
4. $feed = array();
5. foreach ($rss->getElementsByTagName('item') as $node) {
6. $item = array ( 
7. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
8. 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
9. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
10. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
11. );
12. array_push($feed$item);
13. }
14. $limit 5;
15. for($x=0;$x<$limit;$x++) {
16. $title str_replace(' & '' &amp; '$feed[$x]['title']);
17. $link $feed[$x]['link'];
18. $description $feed[$x]['desc'];
19. $date date('l F d, Y'strtotime($feed[$x]['date']));
20. echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
21. echo '<small><em>Posted on '.$date.'</em></small></p>';
22. echo '<p>'.$description.'</p>';
23. }
24.?>

code]
It is a mistake to think you can solve any major problems just with potatoes.

fran86

Ah, I see. Sounds fair complicated. Using the theme based dynamic content seems to be what I am looking for except I don't understand how or why I need to add the placeholder in theme.php, how can I get it where I want? My sidebar or footer. Would it be easier for me to do iframes holder in template and call it in a new page.php?

phill104

You could add it to your theme wherever you want, but you would need to style it to fit.
It is a mistake to think you can solve any major problems just with potatoes.

fran86

Your code you suggested? I'm just trying it now but confused with how to move it... lots of negative margins?

fran86

Just tested it and put in under the online stats but it's just a bunch of code... it's not really where I want it though.

content.php:

<?php

/*************************

  Coppermine Photo Gallery

  ************************

  Copyright (c) 2003-2014 Coppermine Dev Team

  v1.0 originally written by Gregory Demar



  This program is free software; you can redistribute it and/or modify

  it under the terms of the GNU General Public License version 3

  as published by the Free Software Foundation.



  ********************************************

  Coppermine version: 1.5.30

  $HeadURL: https://svn.code.sf.net/p/coppermine/code/trunk/cpg1.5.x/anycontent.php $

  $Revision: 8721 $

**********************************************/



/**

* This file gets included in index.php if you set the option on the configuration panel: "content of the main page".

* It can be used to display any content from any program, it is to be edited according to one's tastes.

*/



if (!defined('IN_COPPERMINE')) {

    die(
'Not in Coppermine...');

}



starttable("100%"$lang_index_php['welcome']);



echo <<< EOT

    <tr>

        <td class="tableb">

            <?php
2.
$rss = new DOMDocument();
3.
$rss->load('http://site.com/feed/');
4.
$feed = array();
5. foreach (
$rss->getElementsByTagName('item') as $node) {
6.
$item = array ( 
7. 'title' => 
$node->getElementsByTagName('title')->item(0)->nodeValue,
8. 'desc' => 
$node->getElementsByTagName('description')->item(0)->nodeValue,
9. 'link' => 
$node->getElementsByTagName('link')->item(0)->nodeValue,
10. 'date' => 
$node->getElementsByTagName('pubDate')->item(0)->nodeValue,
11. );
12. array_push(
$feed$item);
13. }
14.
$limit = 5;
15. for(
$x=0;$x<$limit;$x++) {
16.
$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
17.
$link = $feed[$x]['link'];
18.
$description = $feed[$x]['desc'];
19.
$date = date('l F d, Y', strtotime($feed[$x]['date']));
20. echo '<p><strong><a href="'.
$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
21. echo '<small><em>Posted on '.
$date.'</em></small></p>';
22. echo '<p>'.
$description.'</p>';
23. }
24.?>


        </td>

    </tr>



EOT;



endtable();



?>

Αndré

At first you need to remove the leading line numbers. Then, you need to add the PHP code somewhere it gets parsed.

Something like that:

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2014 Coppermine Dev Team
  v1.0 originally written by Gregory Demar

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

  ********************************************
  Coppermine version: 1.5.30
  $HeadURL: https://svn.code.sf.net/p/coppermine/code/trunk/cpg1.5.x/anycontent.php $
  $Revision: 8721 $
**********************************************/

/**
* This file gets included in index.php if you set the option on the configuration panel: "content of the main page".
* It can be used to display any content from any program, it is to be edited according to one's tastes.
*/

if (!defined('IN_COPPERMINE')) {
    die(
'Not in Coppermine...');
}

starttable("100%"$lang_index_php['welcome']);

echo <<< EOT
    <tr>
        <td class="tableb">
EOT;
$rss = new DOMDocument();
$rss->load('http://site.com/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array ( 
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed$item);
}
$limit 5;
for($x=0;$x<$limit;$x++) {
$title str_replace(' & '' &amp; '$feed[$x]['title']);
$link $feed[$x]['link'];
$description $feed[$x]['desc'];
$date date('l F d, Y'strtotime($feed[$x]['date']));
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}

echo <<< EOT
        </td>
    </tr>

EOT;

endtable();

?>


phill104

Apologies for the line numbering. I left those in as pointers for the required edits and should have done it as comments instead.
It is a mistake to think you can solve any major problems just with potatoes.

fran86

No worries Phill, I probably should have noticed it myself.

Thank you for the correction Αndré. It appears that it's half way there.. there are no posts, only dates with December 31 1969. I have double checked the url of my feed and it's correct.