TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 387
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 121
  • Total: 121

Coppermine Gallery in iFrame - Direct Jump To Album Or Category From Article

Started by tim antley, October 30, 2007, 06:45:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ianedres

Using Coppermine Photo Gallery with TinyPortal and SMF, I had the need to provide my members with a direct link to a CPG album or catergory without losing the portal interface. Using the link provided by CPG resulted in a loss of the blocks and framework of TP, and I wanted to keep a consistent appearance on my site.

This code allows me to specify the CPG album or category by appending '&cat=xx' or '&album=xx' after the '?page=xx' (or '?page=cpg_frameload' using TP's article query titles) in the URL link. I now can make a front page article jump directly to the location, keeping the TP interface intact.

First, add a PHP article to your site using the code below. I prefer to use the query title (not the article's title) that only appears after you save the article. This is more intuitive than using the article's number for future reference. Just one instance of this article is required, as you will call it with parameters in the URL link to load categories or albums dynamically each time.

In the code, set the variable $cpg_path as a relative path to your CPG directory, as it relates to your SMF installation. Most people will need only to use '../cpg_1410' if you installed it directly under your root directory. If you use an absolute path, you must have 'allow_url_fopen = On' in your server's PHP.INI file.

I also provided a set of variables in the code to adjust for your particular display needs; once you set those variables, the code will render the iframe as you have set it in the code. For flexibility, you can optionally specify the variables in the URL to change the appearance of the iframe (in the format of '&scrolling=auto' etc. after all other variables) should you need to. Those variables are 'scrolling', 'frameborder', 'marginwidth', 'marginheight', 'vspace', 'hspace', 'height', and 'width'. The default values should generally fit most installations.

Once you have the article saved (don't forget to set up the display options for right/left/center blocks, etc), you can call it from any other article or post using the link to the article, appending '&cat=xx' or '&album=xx' to the URL.

A sample link would be: "yourdomain.com/index.php?page=cpg_frameload&album=10" which would open album #10. Note the use of the '&' before either 'cat' or 'album'. If you specify both, 'cat' will take priority over 'album'.

The code does not check whether the specified category or album exists or any permissions; CPG will just display the appropriate error message as it would normally.

I welcome all comments and suggestions about the code. The above instructions should suffice for most competent administrators to implement into their site without needing much more detail.


// Iframe Direct Jump To Category Or Album
// 'cpg_frameload.php' : October 29, 2007
// Tim Antley / www.BayouMX.com

// For Use With Coppermine Photo Gallery & SMF/TinyPortal

// Load iFrame For Category Or Album Directly

// Specify 'cat=xx' or 'album=xx' In Load Statement In URL link
// i.e. -> www.domain.com/index.php?page=cpg_frameload&cat=10 <-

$cpg_path = '../cpg_1410'; // Use the relative path to your CPG installation

// Sets Default Values For Frame Parameters; Adjust Once For Your Forum's Display Needs
$scrolling = 'auto'; // Values: 'yes', 'no', or 'auto'
$frameborder = '0';
$marginwidth = '0';
$marginheight = '0';
$vspace = '0';
$hspace = '0';
$height = '2500px'; // Be sure to follow with 'px' after the numerical amount.
$width = '100%'; // Be sure to follow with '%' after the numerical amount.

// No Need To Edit Below This Line
// ______________________________________________________________________________________________

// Dynamically Adjust Frame Parameters From URL Values (Not Usually Needed But Provided For)
if(isset($_GET['scrolling'])) $scroll = $_GET['scrolling'];
if(isset($_GET['frameborder'])) $frameborder = $_GET['frameborder'];
if(isset($_GET['marginwidth'])) $marginwidth = $_GET['marginwidth'];
if(isset($_GET['marginheight'])) $marginheight = $_GET['marginheight'];
if(isset($_GET['vspace'])) $vspace = $_GET['vspace'];
if(isset($_GET['hspace'])) $hspace = $_GET['hspace'];
if(isset($_GET['height'])) $height = $_GET['height'];
if(isset($_GET['width'])) $width = $_GET['width'];

// Default Page To Load If 'cat' or 'album' Not Specified
$var = 'index.php';

// Check For 'cat' Or 'album' In URL; 'cat' Has Priority Over 'album'
if(isset($_GET['cat']))
{
$var = 'index.php?cat='.$_GET['cat'];
}
else
{
if(isset($_GET['album'])) $var = 'thumbnails.php?album='.$_GET['album'];
}

// Output iFrame HTML Statement With Variables
echo '<iframe scrolling="'.$scrolling.'" frameborder="'.$frameborder.'" id="myframe" src="'.$cpg_path.'/'.$var.'" marginwidth="'.$marginwidth.'" marginheight="'.$marginheight.'" vspace="'.$vspace.'" hspace="'.$hspace.'"  height="'.$height.'" style="width: '.$width.'"></iframe>';

// End Of Script


This code works with SMF 1.1.4, TinyPortal 0.9.8, and Coppermine v1.4.10. It it breaks, you own both parts, and is guaranteed for ninety days or ninety feet, whichever comes first. I am not a php coder, but I stayed at Holiday Inn Express one time.

Elrond

LoL I stayed at a Holiday Inn Express one time too! ;D

If you are validating your page output to xhtml 1.0 strict or xhtml 1.1, the iframe component is deprecated in those dtd's, so the object element can be used instead. However it has some fundamental problems in Internet Explorer.

This line:

// Output iFrame HTML Statement With Variables
echo '<iframe scrolling="'.$scrolling.'" frameborder="'.$frameborder.'" id="myframe" src="'.$cpg_path.'/'.$var.'" marginwidth="'.$marginwidth.'" marginheight="'.$marginheight.'" vspace="'.$vspace.'" hspace="'.$hspace.'"  height="'.$height.'" style="width: '.$width.'"></iframe>';


Can be changed to:

<object data="'.$cpg_path.'/'.$var.'" type="text/html" id="myframe" style="width: '.$width.'; height: '.$height.'; padding: '.$vspace.', '.$hspace.'; margin: '.$marginwidth.', '.marginheight.'; border: 0px;">
Your browser does not support objects, but you may view this content
at <a href="'.$cpg_path.'/'.$var.'">here</a>
</object>


If object is not supported, it should display a link to the content. Also, if your CPG link is to a remote domain (say you have your own http server and host multiple sites, but want to refer to a remote domain or even a sub-domain, like cpg may be in a sub-domain) the object element won't work right in Internet Explorer, so it's obvious there has to be a work-around for that. The following is basically the same line, except with using styles for the margins and padding and height and such. If the following didn't work we could simply put the original iframe code between the commented lines and that would work fine.


<!--[if IE]>
<iframe scrolling="'.$scrolling.'" frameborder="'.$frameborder.'" src="'.$cpg_path.'/'.$var.'" id="myframe" frameborder="0" style="width: '.$width.'; height: '.$height.'; padding: '.$vspace.', '.$hspace.'; margin: '.$marginwidth.', '.marginheight.';">
</iframe>
<![endif]-->
<!--[if !IE]> <!-->
<object data="'.$cpg_path.'/'.$var.'" type="text/html" id="myframe" style="width: '.$width.'; height: '.$height.'; padding: '.$vspace.', '.$hspace.'; margin: '.$marginwidth.', '.marginheight.'; border: 0px;">
Your browser does not support objects, but you may view this content
at <a href="'.$cpg_path.'/'.$var.'">here</a>
</object>
<!--<![endif]-->


Additionally, if you ARE displaying object content from the current domain, but that content is xhtml doctype, it will display a border around it. Putting border: 0px; inside the body css style tag should alieve that situation; however if it doesn't it will require the use of an iframe.

Usage of the object element is required for validity if using xhtml 1.0 strict or above but iframe will still work with all currently-operating browsers.

Any spelling or syntactical errors on the above are purely coincidental. :o

This website is proudly hosted on Crocweb Cloud Website Hosting.