Module: Item Links

rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Mon, 2011-06-13 04:19

Item Links is a module for Gallery 3 that allows users to convert existing gallery items (albums/photos/movies) into links to external URLs. Once this module is installed, all items will have a "Redirect to URL" field on the Edit album/Edit photo/Edit movie screens. Simply enter a URL (starting with "http://") into this field and press Modify to save. Afterwards any user trying to visit that items page will be automatically redirected to the specified URL.

The initial release of this module has been tested with Gallery 3.0.2.
[img]http://gallery.menalto.com/files/item_links.png[/img]

---
Report Problems/Suggestions Here | Get latest version | Documentation | Coffee Fund | My Library | My GitHub

AttachmentSize
item_links.png3.84 KB
item_links.zip4.17 KB
 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Mon, 2011-06-13 06:28

Neat!

 
JimW

Joined: 2011-07-15
Posts: 2
Posted: Fri, 2011-07-15 15:07

Nice module, is there a way to add target="_blank"?

Thanks

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Fri, 2011-07-15 18:24
JimW wrote:
Nice module, is there a way to add target="_blank"?

Thanks

No.

Adding a target parameter would require modifying am items link, which this module does not do. This module doesn't modify an item's url, it just changes what happens when someone trys to visit the URL.

So for example, if you have an album called Asdf, and it's url is http://www.example.com/gallery3/index.php/Asdf/ and then you edit it to be a link, it's URL stays the same. However, after making it a link, whenever someone tries to visit http://www.example.com/gallery3/index.php/Asdf/ (either by clicking on the album icon or by accessing the URL directly) they'll get redirected to the specified link instead of seeing the album's contents. Adding additional parameters like target would require functionality completely different from how this module currently works.

 
JimW

Joined: 2011-07-15
Posts: 2
Posted: Fri, 2011-07-15 18:35

Thanks for the info!

G2 worked with pdf's now I have to create a thumbnail and link to a pdf. For some users, depending on their browser settings the pdf will open right on the gallery page. I really need pdf's to open in a new window.

If you have any suggestions they would be very much appreciated. Sure wish G3 worked with pdf.

Thanks

Jim

 
wise_mike

Joined: 2008-10-21
Posts: 158
Posted: Sun, 2011-08-28 22:19

Nice module, thanks..

When creating a redirect album, is there a way to add the option that it uses the thumbnail of the redirect link? I mean when I create an album with a redirect using "Item Link", there is no thumbnail for the album, and I have to upload an image to that album to have it show a thumbnail..

It would be a nice idea that is automatically takes the thumbnail file of the redirect link..

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Fri, 2011-12-30 11:38

Just what I needed

thank you !

 
screenfx
screenfx's picture

Joined: 2012-01-15
Posts: 1
Posted: Sun, 2012-01-15 19:03

Great module. I did screen shots of my youtube videos and placed a play button on top of them and use them for my thumbnails and redirect the thumbnails to the videos.

http://alolkoydesigns.com/index.php

 
nogates

Joined: 2011-04-13
Posts: 26
Posted: Wed, 2012-03-14 03:14

Can it be restricted to admin only?

 
paul4maccarni

Joined: 2012-09-04
Posts: 6
Posted: Wed, 2012-09-05 08:57

Hi All can we the URL open in a new window.

How to do it

Thanks in advance

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-09-05 10:53
 
paul4maccarni

Joined: 2012-09-04
Posts: 6
Posted: Fri, 2012-09-07 05:48

Dave; thanks a lot for the new module.

I was able to install and enable the module. But when i try to edit the photo there was no place to enter the external url. I can see there is only one php file in the module exlinks_new_window_theme.php and no install Installer.php found.

I tried in a fresh installation but no luck

Thanks in advance.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-09-07 14:30

I think you misunderstand.
use this module (item links) and in combination with the exlinks_new_window module all links to external sites will get a new window. The exlinks_new_window requires no configuration. item links module should be installed and working.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
paul4maccarni

Joined: 2012-09-04
Posts: 6
Posted: Sat, 2012-09-08 02:45

Dear Dave; I have tried by enabling both modules but redirection happen as usual, in same window. Do I have to enable some other javascript or different module too?
I can see the new javascript part is loaded in body section.But I am not sure its called when I click the image. I tried both chrome and Firefox browsers.

Following i have attached the picture of enabled modules and loaded Javascript code. you can see both "external link new window" and "item links" modules have been enabled.

Thanks

[img]http://s12.postimage.org/5w56u6yfh/Screenshot_from_2012_09_08_07_51_46.png[/img]
--------------------------------------------------------------------
[img]http://s11.postimage.org/m8dg233sz/Screenshot_from_2012_09_08_07_54_45.png[/img]

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-08 05:21

OK it does not work.
http://gallery.menalto.com/node/102548#comment-377846
sorry.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-08 16:43

A bit of a kluge but this might help... use this as the helpers/item_links_theme.php:

class item_links_theme_Core {
  static function head($theme) {
    // If the current page is an item, and if it's in the item_links table,
    //   then redirect to the specified web page.
    if ($theme->item()) {
      $item_url = ORM::factory("item_link")
        ->where("item_id", "=", $theme->item->id)
        ->find_all();
      if (count($item_url) > 0) {
	    // If the url has a target= in it then open a new window.
		if (strpos($item_url[0]->url,'target=') !== false) {
		  $str = substr($item_url[0]->url, 0, strrpos($item_url[0]->url, ' '));
		  return "<script type=\"text/javascript\">" .
		    "window.open('" . $str . "'); window.history.back();" . 
		    "</script>";
		}
		else {
        url::redirect($item_url[0]->url);
		}
      }
    }
    return;
  }
}

When editing the url just add a space and a target= at the end. like:
http://example.com target=blank

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
paul4maccarni

Joined: 2012-09-04
Posts: 6
Posted: Mon, 2012-09-10 10:19

Hi Dave;

Thanks a lot for the code and this is what exactly i wanted to do. But there is a known issue that all browsers are blocking popup boxes by default. There fore i changed the code into use a javascript dropin box.

First you need to download and host dropincontentbox.css, jquery.easing.1.3.js, dropincontentbox.js files from following link.
http://www.dynamicdrive.com/dynamicindex17/dropinbox.htm

Then create and host advertisement/external html pages separately.

changed the helpers/item_links_theme.php code as following

class item_links_theme_Core {
  static function head($theme) {
    // If the current page is an item, and if it's in the item_links table,
    //   then redirect to the specified web page.
    if ($theme->item()) {
      $item_url = ORM::factory("item_link")
        ->where("item_id", "=", $theme->item->id)
        ->find_all();
      if (count($item_url) > 0) {
            // If the url has a target= in it then open a new window.
                if (strpos($item_url[0]->url,'target=') !== false) {
                  $str = substr($item_url[0]->url, 0, strrpos($item_url[0]->url, ' '));

		return "<link rel=\"stylesheet\" href=\"http://localhost/resources/dropincontentbox.css\" />
		<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js\"></script>
		<script src=\"http://localhost/resources/jquery.easing.1.3.js\"></script>
		<script src=\"http://localhost/resources/dropincontentbox.js\">
		</script>
		<script>

		var dropinbox1=new dropincontentbox({
	        	source:['#dropbox', '" . $str . "'], 
	        	cssclass:'dropinbox standardshadow',
	       	 showduration:20 
		})
		</script>";


                }
                else {
        url::redirect($item_url[0]->url);
                }
      }
    }
    return;
  }
}

Now when you edit the url set the hosted advertisement page as the url with target parameter.

--------------------------------------------------
..................................................
==================================================

Now when you click on the image it will load the html page loaded java-script dropin box as follows.

[img]http://s16.postimage.org/dtz0jypzp/Screenshot_from_2012_09_10_15_16_38.png[/img]

Thanks for the great community help,

 
smallIT

Joined: 2012-10-28
Posts: 7
Posted: Mon, 2012-11-05 08:18

The "View fullsize" of an image to redirect, any idea on how to add such an option in the Item Links module? I thought I would be clever and get around the video file size limitation the old fashioned way. I created a still image and redirect it to the raw video file. Bypassing Flowplayer plays fine in the browsers that I need the video to play. However, I wish to not have the photo redirect from the album view, but from image view. Having the option to replace "full size" of the image with a redirect link would be nice. Apparently I am not clever enough to figure it out on my own, so if there are any ideas... ;)


* Gallery Version: 3.0.4 (Ricochet) * Gallery Wind Theme *