Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Display rss feeds (with date) from outside coppermine?  (Read 4379 times)

0 Members and 1 Guest are viewing this topic.

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Display rss feeds (with date) from outside coppermine?
« on: June 08, 2015, 07:18:36 am »

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.
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4659
    • Windsurf.me
Re: Display rss feeds (with date) from outside coppermine?
« Reply #1 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.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Re: Re: Display rss feeds (with date) from outside coppermine?
« Reply #2 on: June 08, 2015, 11:34:02 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. :/
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4659
    • Windsurf.me
Re: Display rss feeds (with date) from outside coppermine?
« Reply #3 on: June 08, 2015, 12:21:30 pm »

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.)

Code: [Select]
[/<?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]
Logged
It is a mistake to think you can solve any major problems just with potatoes.

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Re: Display rss feeds (with date) from outside coppermine?
« Reply #4 on: June 08, 2015, 12:35:09 pm »

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?
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4659
    • Windsurf.me
Re: Display rss feeds (with date) from outside coppermine?
« Reply #5 on: June 08, 2015, 12:46:26 pm »

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

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Re: Display rss feeds (with date) from outside coppermine?
« Reply #6 on: June 08, 2015, 12:48:02 pm »

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

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Re: Display rss feeds (with date) from outside coppermine?
« Reply #7 on: June 08, 2015, 12:54:39 pm »

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:

Code: [Select]
<?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();



?>
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15750
Re: Display rss feeds (with date) from outside coppermine?
« Reply #8 on: June 09, 2015, 08:58:31 pm »

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:
Code: [Select]
<?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();

?>

Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4659
    • Windsurf.me
Re: Display rss feeds (with date) from outside coppermine?
« Reply #9 on: June 09, 2015, 09:40:37 pm »

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

fran86

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 61
Re: Display rss feeds (with date) from outside coppermine?
« Reply #10 on: June 10, 2015, 07:58:38 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 21 queries.