user-gallery: backlink to entries -> static pages!?

Creating and modifying plugins.
Post Reply
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

user-gallery: backlink to entries -> static pages!?

Post by stm999999999 »

hello again, it is about the user-gallery, the next time :-)

In the gallery on an image page I get a link to all articles, which are using these image. It is possible to get a backlink to static pages as well?
Ciao, Stephan
SirRobert
Regular
Posts: 38
Joined: Fri Oct 14, 2005 12:18 am

Post by SirRobert »

This feature would be useful. I think it's not too difficult to make it compatible with static pages, too. Here is the code where the user-gallery searches for the images in the news-entries.
$q = "SELECT e.id, e.timestamp, e.title
FROM {$serendipity['dbPrefix']}entries AS e
WHERE (MATCH(e.title, e.body, e.extended) AGAINST ('" . serendipity_db_escape_string($big) . "')
OR MATCH(e.title, e.body, e.extended) AGAINST ('" . serendipity_db_escape_string($thumb) . "'))
AND (e.body REGEXP '(" . preg_quote(serendipity_db_escape_String($thumb)) . "|" . preg_quote(serendipity_db_escape_string($big)) . ")'
OR e.extended REGEXP '(" . preg_quote(serendipity_db_escape_String($thumb)) . "|" . preg_quote(serendipity_db_escape_string($big)) . ")')
ORDER BY e.timestamp DESC";
$e = serendipity_db_query($q, false, 'assoc');
I think we would only have to change a few variables in this database query and some other litte changes to make it work with staticPages. But I'm not that familiar with staticpages and Mysql. Who knows?

Robert
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I added a basic function to do this and updated CVS (the main php file, the language file, and plugin_imagedisplay.tpl).

It checks that the staticpage class exists before it runs, so it shouldn't interfere with anyone who doesn't have static pages installed. This might require you to reorder your event plugins, though, so that static page is before usergallery (I don't think it does, though).

I did not add a configuration setting to control it; it is wrapped in the entries control (so the display entries setting must be turned on). If folks want a separate configuration setting I can go back and do that when I have more time.

Also, I'm not familiar with Garvin's RSS feed code, so I did not include the staticpage list in the RSS feed. I will take a look at that when I get a chance (if people think it is needed).
SirRobert
Regular
Posts: 38
Joined: Fri Oct 14, 2005 12:18 am

Post by SirRobert »

Hi Matthew,

wow! thank you very much for this quick bugfix!

Robert
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

I tried it yesterday and it works fine! Thanks!
Ciao, Stephan
Post Reply