11: ADDING CONTENTdm TO A WORDPRESS SITE

Adding a CONTENTdm record to a WordPress site is very easy, once you get a Plugin called Insert PHP (http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin.php).

This plugin allows you to drop in and run PHP code directly. I will adopt the program dmGetItemInfoWebPage.php from previous:

<?php

$collection = "linl";
$pointer = 22;

$xmlData = file_get_contents("https://server16614.contentdm.oclc.org/dmwebservices/index.php?q=dmGetItemInfo/$collection/$pointer/xml");
$fieldData = file_get_contents("https://server16614.contentdm.oclc.org/dmwebservices/index.php?q=dmGetCollectionFieldInfo/$collection/xml");

$sxe = new SimpleXMLElement($xmlData);

$xml = simplexml_load_string($xmlData);
$fieldData = simplexml_load_string($fieldData);

foreach ($fieldData->xpath('//field') as $record) {
        $result[] = array(
                'nick' => (string) $record->nick,
                'name' => (string) $record->name
        );
}
function searchForId($id, $array) {
   foreach ($array as $key => $val) {
       if ($val['nick'] === $id) {
           return $key;
       }
   }
   return null;
}
?>
                <div id="list">
                        <center>
                                <?php
                                        $imageXMLData = file_get_contents("https://server16614.contentdm.oclc.org/dmwebservices/index.php?q=dmGetImageInfo/$collection/$pointer/xml");
                                        $imageXML = simplexml_load_string($imageXMLData);
                                        $height = $imageXML[0]->{'height'};
                                        $width = $imageXML[0]->{'width'};
                                        if ($width > 800) {
                                                $percentage = (800 / $width) * 100;
                                        }
                                        echo "<img src=\"http://www.idaillinois.org/utils/ajaxhelper/?CISOROOT=$collection&CISOPTR=$pointer&action=2&DMSCALE=$percentage&DMWIDTH=$width&DMHEIGHT=$height&DMX=0&DMY=0\">\n"; ?>
                        </center>
                        <p />
                        <table border="1">
                        <?php
                                foreach ($sxe->children() as $child) {
                                        $str = $child->getName();
                                        $title = $xml[0]->{"$str"};
                                        $id = searchForId($str, $result);
                                        if (isset($id)) {
                                                $fieldName = $result[$id]["name"];
                                                echo "<tr><td width=\"25%\"><strong>$fieldName</strong></td>\n";
                                                echo "<td width=\"75%\">$title</td></tr>\n";
                                        }
                                }
                        ?>
                        </table>
                </div>

I have removed the <HTML>,<HEAD>, and <BODY> tags and the Header and Footer sections. I have also modified the <?php tags and the closing ?>. This allows the plugin to interpret and execute the code. Here is an image and text of Wrong Way Corrigan coming to Springfield:

Douglas ‘Wrong Way’ Corrigan

Douglas Corrigan (January 22, 1907 – December 9, 1995) was an American aviator born in Galveston, Texas. He was nicknamed “Wrong Way” in 1938. After a transcontinental flight from Long Beach, California, to New York, he flew from Floyd Bennett Field in Brooklyn, New York, to Ireland, though his flight plan was filed to return to Long Beach. He claimed his unauthorized flight was due to a navigational error, caused by heavy cloud cover that obscured landmarks and low-light conditions, causing him to misread his compass. However, he was a skilled aircraft mechanic (he was one of the builders of Charles Lindbergh’s Spirit of St. Louis) and had made several modifications to his own plane, preparing it for his transatlantic flight. He had been denied permission to make a nonstop flight from New York to Ireland, and his “navigational error” was seen as deliberate. Nevertheless, he never publicly admitted to having flown to Ireland intentionally. (CITATION)


Title Douglas ‘Wrong Way’ Corrigan
Creator
Contributors
Subject [LCSH] Corrigan, Douglas, 1907-
Subject [Local] Municipal Airport
Browse Topic Transportation & Communication
Description Douglas ‘Wrong Way’ Corrigan at Municipal Airport, Springfield, Illinois.
Date Original 1938-08-22
Date 1938
Time Period 1930s (1930-1939);
Source
Relation.IsPartOf Sangamon Valley Collection, Southwest Airport Collection, Box 2, Folder 28
Language
Geographic Coverage United States–Illinois–Sangamon County–Springfield
Contributing Institution Lincoln Library
Rights Contact Lincoln Library, 326 South 7th Street, Springfield, Illinois, (217) 753-4900 for information concerning copyright restrictions applying to the use or reproduction of this image.
Date Digital 2004-06-17
Identifier llsa0054
Type Image
Format Photograph
Digital Format JPEG
Digitization Specifications TIFF images created with CanoScan 9900F scanner, 300 DPI, grayscale, ArcSoft Photo Studio 5
Transcript
Tag
Collection Name Springfield Aviation Company Collection
Full resolution
CONTENTdm file name 23.jpg
Date created 2004-11-15
Date modified 2009-12-02
OCLC number
CONTENTdm number 22