• I have a custom template that pulls a list of files (images in this case) from a specific directory, and then “tries” to execute the special tags accompanied for it. So far, the page will populate the images as a page – however it seems to ignore the tags the plugin uses (the plugin being Iimage Gallery).


    <?php
    /*
    Template Name: Gallery
    */
    ?>
    <?php
    function CheckExt($filename, $ext) {
    $passed = FALSE;
    $testExt = "\.".$ext."$";
    if (eregi($testExt, $filename)) {
    $passed = TRUE;
    }
    return $passed;
    }

    //Define an array of common extensions.
    $exts = array("gif","jpg$|\\.jpeg","png","bmp");

    //xhtml fluff needed
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\"http://www.w3.org/1999/xhtml\">

    <head profile=\"http://gmpg.org/xfn/11\">
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />

    <title>Gallery Page Test</title>

    <meta name=\"generator\" content=\"WordPress 1.5.2\" />";
    echo "<style type=\"text/css\" media=\"screen\"></style></head>
    <body>";
    echo "<b>Images in this folder:</b><gallery crop=\"true\" crop_center=\"true\" max_side=\"100\" quality=\"95\" stand_alone=\"true\">";
    $dir = opendir("/website/public_html/wp2/wp-content/gallery");
    $files = readdir($dir);

    while (false !== ($files = readdir($dir))) {
    foreach ($exts as $value) {
    if (CheckExt($files, $value)) {
    echo "<img src=\"wp-content/gallery/$files\" />\n";
    $count++; //Keep track of the total number of files.
    break; //No need to keep looping if we've got a match.
    }
    }

    }
    echo "</gallery>\n";
    echo $count." image(s) found in this directory.\n";
    echo "Refresh\n";
    echo "</body></html>";
    //Be a good script and clean up after yourself...
    closedir($dir);

    ?>

    The use of \” is manditory for echo when using quotes. The output (view source the new page) is:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title>Gallery Page Test</title>

    <meta name="generator" content="WordPress 1.5.2" /><style type="text/css" media="screen"></style></head>
    <body><b>Images in this folder:</b><gallery crop="true" crop_center="true" max_side="100" quality="95" stand_alone="true"><img src="wp-content/gallery/m0302.jpg" />
    <img src="wp-content/gallery/S03.jpg" />
    </gallery>
    2 image(s) found in this directory.
    Refresh

    </body></html>

    The result is the same for WP 1.5x and 2.x
    Typically when a page or a blog entry uses the gallery tags (the iimage-gallery plugin), its rendered/replaced with thumbnails and links to the original size images.

    Reason behind the madness: Trying to make a dynamic Page, that updates the picture gallery, whenever a new picture is added to the specific directory. True there are other gallery systems out there, such as lazyest – but I like this one. I’d prefer using this one.

    I’ve sent off a couple emails to the creator but haven’t heard from him, so I’m trying here, to see if theres something I’m missing/why the plugins won’t execute as a custom Page template.

Viewing 1 replies (of 1 total)
  • Thread Starter dementis

    (@dementis)

    I got a response from the creator of Iimage Gallery. Not sure how to approach this in a template manner.

    “IIG works as a filter. Read a bit about plugins on codex.wordpress.org and then you’ll realise that what you need is to pass the “text” into several functions from IIG to make it work. Each function does something else (creates thumbnails, renders gallery, etc.)”

    hrm… 😛

Viewing 1 replies (of 1 total)
  • The topic ‘“executing” a plugin inside of a custom template?’ is closed to new replies.