Sozu Web Studio - Stylish Accessibility

Sozu Web Studio Logo

How Does AMM Work?

The Amazon Media Manager (AMM) allows you to display the data stored in your AMM database through the use of two things:

It allows you to insert the function amm_getMedia into your blog in two ways:

Don't worry, we'll be explaining how to do all of this in detail below.

The amm_getMedia() Function

This main function is what provides the flexibility to AMM. Those of you who have played around with Wordpress will know that to get your posts and stuff onto your blog, you use what are called "Hook Functions".

The getMedia function is just such a function, and it takes 5 parameters. All of these parameters are optional, as the function has a "Safe default" state.

The full function call looks like this:

    amm_getMedia(template, items, group, sort, rating);

Usually you'll be calling the function from within a template and with some proper values, so you'll more than likely have something like this in your template:

    <?php amm_getMedia('amm_default_output', 3, AMM_ALL); ?>

Calling the Function

We said this could be done in two ways, we weren't lying. The first method is to insert the function call into your template. Lots of people use it in their sidebar but because of the way WP1.5 lets you apply different templates all over the place, you can put amazon stuff anywhere you like! See the example:

<?php amm_getMedia('template', 3, AMM_ALL, AMM_DATE_DESC, AMM_RATING_ALL); ?>

The second way to do it, is to enter the function call as a quicktag into any page or any post, like so:

<!--amm_getMedia('template', 3, AMM_ALL, AMM_DATE_DESC, AMM_RATING_ALL)-->

Note When inserting the function as a quicktag, you don't need the & lt;?php tag, it's closing ?> tag and you don't need the semi-colon on the end either. If you have problems, refer back to this and make sure yours looks the same.

One final thing you must do to activate the 'Quicktag' in that post is to add a custom field to the post. To do this, when you're writing the post press the "Advanced Editing" button (It's next to publish) and then look down for a section called "Custom Fields"

Advanced editing button:

The Advanced editing button

Custom Fields area:

The Custom Fields area

Simply enter a new custom field with the following values:

key     :  amm
value   :  enabled

If you want to turn off the feature for the post you are editing, simply change the key value to disabled

Now, to explain those parameters... Skip to examples!

template

This should be set to the name of the template you wish to use to display the AMM data. There is no limit to the number of templates you can create, but you do have to create some! We'll get to that later.

This is a string, and must have single quotes around it.

items

This is an integer (Whole number) and does not need single quotes.

This controls how many items are displayed, so if you want to see 5 things, use the nubmer 5, that's it.

If you want to show as many items as AMM can find, pass 0 (zero).

groups

For this parameter you use a pre-defined 'Constant'. You type the constant in UPPERCASE, and you do not need to put single quotes around it.

This is where you decide which item types you would like to display. The default of (AMM_ALL) will display items from every category. We are using Amazon's "ProductGroup" to index things by, we didn't choose this, Amazon made us use it, so it's not ideal but it will do.

Here is a list of all available groups and what they will return:

These are all defined in the amm_constants.php file. Examine this file and you should be able to make your own groups by copying how groups like AMM_HOME and AMM_SW were made.

If you want to pass a selection of items too the getMedia function, pass them through as shown below, using the 'pipe' to separate the terms, eg:

    AMM_WATCH|AMM_BOOKS|AMM_PHOTO

The above example would display Watches, Books and Photographic equipment.

sort

For this parameter you use a pre-defined 'Constant'. You type the constant in UPPERCASE, and you do not need to put single quotes around it.

This parameter lets you decide how the returned items are sorted.

Default: AMM_DATE_DESC

5 values are available:

The default will display the most recent items first.

rating

$Rating

For this parameter you use a pre-defined 'Constant'. You type the constant in UPPERCASE, and you do not need to put single quotes around it.

This parameter lets you filter the results based on the ratings you have given the items you store.

Default: AMM_RATE_ALL (Display all ratings)

This lets you filter your results based on the ratings they have. There are several possible values, explained below:

Using these it should be possible to filter your outputs in as many combinations as you please.

Example Functions

Below are some examples of how to call amm_getMedia. Use these to learn from so you find it easier to write your own:

    Get 3 of your latest books:
    amm_getMedia('amm_default_output',3,AMM_BOOKS,AMM_DATE_DESC,AMM_RATING_ALL);

    Get 1 random movie, which you rated more than 3:
    amm_getMedia('amm_default_output',1,AMM_DVD,AMM_RANDOM,AMM_RATING_3UP);

    Get all watches and clothes, sort by rating with the highest first:
    amm_getMedia('amm_default_output',0,AMM_WATCH|AMM_APPAREL,AMM_RATING_DESC);

Remember, if you want to leave a parameter out, you must leave the commas in!

    3 items, any rating, with default sort and category:
    amm_getMedia('amm_default_output',3,,,AMM_RATING_ALL);

The getMediaID() function

This function is used when you want to get a specific, single item out from the database. You must first know it's ID, get this by looking in the AMM Management page and remembering the ID you want to display.

Next, call the function just like you'd call the standard amm_getMedia(), but this time you need only two parameters, like so:

    <?php amm_getMediaID('template_name',45);?>

            OR for quick-tag use:

    <!--amm_getMediaID('template_name',45)-->

Obviously, change 'template_name' to the template you want to use and change the 45 to the id of the item you want to display.

Creating AMM Templates

Please refer to Creating Templates for instructions!

References

All content is ©Sozu Ltd. 2005

Sozu Watermark