DM Albums External Usage Update
November 4th, 2009
In order to make it easier to use DM Albums outside your WordPress blog, the Productions has released a new file to the DM Albums project called dm-albums-external.php which does all the setup discussed in the article about using DM Albums outside your blog. This file will be available as part of the DM Albums distribution starting with v2.3.2 (not yet released as of this writing), but for those of you who want to start using this file now, you can download it and copy it into your dm-albums plugin folder.
dm-albums-external.php does all the setup required for connecting to WordPress and provides a functions called printalbum which makes the call to the plugin function to display the album. The function definition is:
function dm_printalbum($directory)
The only parameter is $directory which is the filesystem path to your album, relative to your Home Folder setting. (If you use the absolute path, that’s OK because the printalbum function will fix that for you.)
All you have to do is to include the dm-albums-external.php file into your php script, and call dm_printalbum whereever you’d like to show the album.
Your code should look something like this (you would have to modify your include path to point at the dm-albums-external file correctly):
<?php
include($_SERVER["DOCUMENT_ROOT"] . “/wp-content/plugins/dm-albums/dm-albums-external.php”);
dm_printalbum(“/wp-content/plugins/dm-albums/preview/”);
?>
» View the Demo.
dm-albums-external.php
Posted in Advanced Usage, DM Albums, Latest News & Announcements | 1 Comment »
Using DM Albums Outside Your Blog
November 3rd, 2009
Several users have asked how to add DM Albums outside their blogs. Since DM Albums is plugged into your blog by making a reference to an HTML IFRAME that points to your DM Albums app and photo album, this is quite a simple thing.
There are two ways to embed DM Albums into your website outside of WordPress: The WordPress Way (recommended) and the Do-It-Yourself Way.
The WordPress Way
Either way is fine, but lets start with the WordPress way. Suppose your blog is located at http://mydomain.com/blog/ and the website your want to show the DM Album on is located at http://mydomain.com/. Lets also say the page you want to show your album in is called http://mydomain.com/myalbums.php.
First, you’ll have to include the stuff from WordPress that makes WordPress work. That’s pretty easy, since WordPress supplies a file just for this kind of thing. It’s called wp-load.php and all you have to do is include it and your script will know everything there is to know about your blog. The only tricky bit is to figure out where this file lives, relative to your script. For our example, this would be dirname(dirname(__FILE__)) . "/blog/wp-load.php".
Next, we need to know what album it is that we want to show, set through the currdir parameter. DM Albums are really just directories with photos in them (and a file that stores information about your album like captions and an album name). That means we need to know the directory, relative to the Home Directory setting set up in the DM Albums Options panel and set currdir equal to that. Lets use the DM Albums preview album for this purpose, which is located in your DM Albums preview folder here: /wp-content/plugins/dm-albums/preview/. If your Home Directory is set to the default, your currdir would be /blog/wp-content/plugins/dm-albums/preview/.
Finally, all we need to do is call the dm_getalbum with the query string to tell it which album we’re talking about. The complete code looks something like this:
<?php
require_once(dirname(dirname(__FILE__)) . "/blog/wp-load.php");
$currdir = "/wp-content/plugins/dm-albums/preview/";
print(dm_getalbum("?currdir=$currdir"));
?>
This will look exactly like it does in your blog, including all the custom settings you set up in the DM Albums Options panel:
Do-It-Yourself Way
The Do-It-Yourself Way way involves less of the PHP programming, but you still need to know what the currdir should be. (It’s the same as above, except with HTML you can’t use a variable.) The, you just paste some HTML for an IFRAME and you should be all set:
The results should look something like this:
Posted in Advanced Usage, DM Albums | 1 Comment »