Imageblock.External - modify link target
|
wogri
Joined: 2005-10-06
Posts: 8 |
Posted: Thu, 2005-10-06 08:05
|
|
Hi! I like the imageblock.external feature a lot. Unfortunately there doesn't seem to be a possibility to modify the link target. I would like to have either no link at all, or sometimes different targets. That shouldn't be a big patch. Is it possible to implement this? I'd like something like this: @readfile('http://my.gallery.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=weeklyImage&g2_show=title&g2_itemId=39907&link=http://www.google.com' and: @readfile('http://my.gallery.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=weeklyImage&g2_show=title&g2_itemId=39907&link=none' If the creator of this module could write this up - shouldn't take him longer than an hour to do this... thanks |
|
| Login or register to post comments |

Posts: 32356
heh, thanks for estimating the time to implement this ;)
you can file a feature request on http://sf.net/projects/gallery/ for it, there are lots of small requests, so this probably won't be implemented very soon... of course you're free to submit a patch.
Posts: 8
Well... instead of waiting, I'll submit a patch - sooner or later.
Though it might take me 3 hours instead of one
wogri
Posts: 8598
doesn't site admin / imageblock list a param called linkTarget?
Posts: 32356
isn't the linktarget argument to specify whether to open the links in the windows (<a href= ... target=...)?
Posts: 8
the linkTarget is what valiant describes. here's my patch to achieve what I wanted. After patching you have an extra parameter called 'g2_link' which can have the options 'none' or 'linkname'. If g2_link is not defined, the default link to the gallery itself is applied. If set to none, it won't link anywhere, and if set to e.g http://www.google.com it will link there.
example:
<?php @readfile('http://gallery.on.my.server/gallery/main.php?g2_view=imageblock.External&g2_blocks=weeklyImage&g2_show=title&g2_itemId=39907&g2_link=http://www.google.com'); ?>
Here's the patch (which took me 2 hours), please let me know if you'll merge it in to your main galler code, I would be very happy about that!
(apply with patch -p0 in the modules/imageblock directory).
diff -Nur ../imageblock.bak/External.inc ./External.inc
--- ../imageblock.bak/External.inc 2005-08-23 05:49:43.000000000 +0200
+++ ./External.inc 2005-10-08 11:20:25.000000000 +0200
@@ -64,7 +64,7 @@
$frameIds = array();
$params = array('maxSize' => null);
foreach (array('blocks', 'show', 'itemId', 'maxSize',
- 'linkTarget', 'itemFrame', 'albumFrame') as $key) {
+ 'linkTarget', 'itemFrame', 'albumFrame', 'link') as $key) {
$tmp = GalleryUtilities::getRequestVariables($key);
if (!empty($tmp)) {
$params[$key] = $tmp;
diff -Nur ../imageblock.bak/classes/ImageBlockHelper.class ./classes/ImageBlockHelper.class
--- ../imageblock.bak/classes/ImageBlockHelper.class 2005-09-07 12:32:17.000000000 +0200
+++ ./classes/ImageBlockHelper.class 2005-10-06 12:19:33.000000000 +0200
@@ -111,6 +111,9 @@
if (isset($params['linkTarget'])) {
$ImageBlockData['linkTarget'] = $params['linkTarget'];
}
+ if (isset($params['link'])) {
+ $ImageBlockData['link'] = $params['link'];
+ }
if (!empty($blocks)) {
/* Prepare image frames, if available */
diff -Nur ../imageblock.bak/templates/ImageBlock.tpl ./templates/ImageBlock.tpl
--- ../imageblock.bak/templates/ImageBlock.tpl 2005-09-01 20:53:46.000000000 +0200
+++ ./templates/ImageBlock.tpl 2005-10-08 11:17:51.000000000 +0200
@@ -9,13 +9,18 @@
{if !empty($block.title)}
<h3> {g->text text=$block.title} </h3>
{/if}
-
- {capture name="link"}
- <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$block.id`"}" {strip}
- {if isset($ImageBlockData.linkTarget)}
- target="{$ImageBlockData.linkTarget}"
- {/if}{/strip}>
- {/capture}
+ {if empty($ImageBlockData.link)}
+ {capture name="link"}
+ <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$block.id`"}" {strip}
+ {if isset($ImageBlockData.linkTarget)}
+ target="{$ImageBlockData.linkTarget}"
+ {/if}{/strip}>
+ {/capture}
+ {else}
+ {if $ImageBlockData.link != 'none'}
+ <a href="{$ImageBlockData.link}">
+ {/if}
+ {/if}
{if $block.item.canContainChildren}
{assign var=frameType value="albumFrame"}
{else}
@@ -34,7 +39,9 @@
{g->container type="imageframe.ImageFrame" frame=$ImageBlockData.$frameType}
{$smarty.capture.link}
{g->image item=$imageItem image=$block.thumb id="%ID%" class="%CLASS%" maxSize=$maxSize}
- </a>
+ {if $ImageBlockData.link !='none'}
+ </a>
+ {/if}
{/g->container}
{else}
{$smarty.capture.link}
diff -Nur ../imageblock.bak/templates/blocks/ImageBlock.tpl ./templates/blocks/ImageBlock.tpl
--- ../imageblock.bak/templates/blocks/ImageBlock.tpl 2005-07-29 05:22:02.000000000 +0200
+++ ./templates/blocks/ImageBlock.tpl 2005-10-06 12:42:38.000000000 +0200
@@ -7,6 +7,7 @@
{g->callback type="imageblock.LoadImageBlock"
blocks=$blocks|default:null maxSize=$maxSize|default:null
itemId=$itemId|default:null linkTarget=$linkTarget|default:null
+ link=$link|default:null
useDefaults=$useDefaults|default:true
showHeading=$showHeading|default:true
showTitle=$showTitle|default:true showDate=$showDate|default:true
Posts: 32356
wogri,
cool
can you please submit your patch to the Patches tracker on http://sf.net/projects/gallery/ ?
thanks!
Posts: 82
nice patch
i was requesting something similar a week ago. thanx
now, this patch should be expanded and such an alternative link option should be available for ANY album, also within the main Gallery enovironemt
http://gallery.menalto.com/node/37747
Posts: 8
I submitted the patch on sf. though I forgot to prefix it with [g2], and as I submittet anonymously, I can't change it anymore, sorry for that.
http://sourceforge.net/tracker/index.php?func=detail&aid=1318485&group_id=7130&atid=307130
ID is: 1318485
Thanks for merging into the main gallery code!
wogri
Posts: 8
To Haplo:
Thanks for liking my patch. I won't expand to your needs though, as I am a networker, not an programmer.
If you find bugs in my patch I will try correct it, but I won't (just not a good programmer here) go into the core gallery code.
wogri
Posts: 44
Hi:
Was this one included in v2.01?? If not, How I could access this functionality??
Thanks
note:
I found out how to patch it.
Posts: 8598
this didn't make it into 2.1, sorry.. but it is in CVS now. thanks!
Posts: 44
Hi:
IS this included in Gallery 2.2 SVN? g2_linkTarget is not working here with the image block.
Later
Posts: 32356
yes. see site admin -> imageblock
Posts: 44
Hi Valiant:
g2_linkTarget is NOT working. It keeps goin into Gallery 2 url for photo in the block.
Setup: Gallery 2.2 rev 15139, PHP 5.2.0, Apache 2.2.3, LINUX RHEL 4, MySQL 4.1.21
Later
Posts: 44
Hi again:
Well, it is somekind strage here is what I found. The linkTarget works this way:
<?php
include('http://sitename/gallery2/main.php?g2_view=imageblock.External&g2_show=none&g2_linkTarget=_blank');
?>
IF I try with @readfile, the g2_linkTarget is not executed... At least the first way works...
Later
Posts: 44
Hi again:
Finally it is working as I want. I am posting the code so others may use it...
<?php
include('http://www.sitename.com/modules/Gallery2/gallery22/main.php?g2_view=imageblock.External&g2_show=none&g2_link=http://www.sitename.com/Gallery2.phtml&g2_linkTarget=_blank');
?>
This makes the image block open new browser window AND refer to the url provided. Still need to tweak to show more than one picture but that should be easy, IMO.
Regards!
p.d.
It is weird, if I use the amp; after &, the block stop working and behaves without following the linkTarget. So I out back the & sign alone and it works again.
Posts: 32356
use & in html and & in php. the include() command is php, thus you should use & there.
Posts: 44
One more question...
How I can use width and heigh with this approach? I mean specifying a block size without editing the template and making it 'general'... Want to be able to use diffrent size for a block...
Later

Posts: 7
I don't know a lot about making changes, but what file do I add the code to to get this to work?
Posts: 5
Thank you so much for implementing this mod. Being able to specify the destination for the link was exactly what I needed. At first I was a bit nervous about upgrading my installation from the nightly updates, but everything seems to be working fine. And it went quite smoothly.
Thanks again for everything Gallery2 related.