I created a small module that adds a "target audience" property for each amazon node. When someone edits the amazon node, s/he is able to tick checkboxes to specify the target audience for the amazon item, by default it is "Beginner, Intermediate, Advanced", but this is configurable in the module's settings.
The <theme>_amazon_node function needs to be created/modified in order to display the target audience, here is mine with zen theme:
/**
* Custom amazon_node display
*/
function zen_amazon_node($node) {
$module_dir = drupal_get_path('module', 'amazon');
$output = '';
$output .= '<table class="amazontools_table">';
$output .= '<tr>';
$output .= "<td><a href=\"$node->detailpageurl\" target=\"_blank\">";
if ($node->mediumimageurl) {
$output .= "<img src=\"$node->mediumimageurl\" height=\"$node->mediumimageheight\" width=\"$node->mediumimagewidth\" alt=\"cover of $node->title\" />";
}
else {
$output .= "<img src=\"$module_dir/images/missingm.gif\" height=\"150\" width=\"100\" alt=\"no image\" />";
}
$output .= "</a></td><td>";
if ($node->type == 'amazon') {
if ($node->detailpageurl) {
$output .= "<a href=\"$node->detailpageurl\" target=\"_blank\">";
}
$output .= $node->product_title . '<br /><br />';
if ($node->detailpageurl) {
$output .= '</a>';
}
}
if ($node->author) {
$output .= 'author: ' . implode('<br />', $node->author) . '<br />';
}
if ($node->rating) {
$output .= "rating: <img src=\"/$module_dir/images/rating$node->rating.gif\" alt=\"\" /><br />";
}
if ($node->asin) {
$output .= 'asin: ' . $node->asin . '<br />';
}
if ($node->binding) {
$output .= "binding: $node->binding <br />";
}
if ($node->listformattedprice) {
$output .= "list price: $node->listformattedprice $node->listcurrencycode <br />";
}
if ($node->formattedprice) {
$output .= "amazon price: $node->formattedprice $node->currencycode<br /><br />";
}
$audience = db_fetch_object(db_query("SELECT audience FROM {amazon_audience_items} WHERE nid = '%d'", $node->nid));
if ($audience) {
$result = db_query("SELECT aid, name FROM {amazon_audiences}");
$audiences = array();
while ($row = db_fetch_object($result)) {
if (_amazon_audience_book($audience->audience, $row->aid)) {
$audiences[] = $row->name;
}
}
if (count($audiences)) {
$output .= "Target audience: ". implode(", ", $audiences) ."<br clear=\"all\" />";
}
}
$output .= '</td>';
$output .= '</tr>';
$output .= '</table><br />';
return $output;
}See the attached tar.gz archive for the amazon_audience module.
| Comment | File | Size | Author |
|---|---|---|---|
| amazon_audience.tar_.gz | 1.91 KB | bicou |
Comments
Comment #1
MGParisi commentedI am not going to include this patch in my update. Due to the fact that it doesn't use taxonomy, and that is what taxonomy is for.
I will attempt to get a taxonomy solution ready, but I am very busy! I do not own the project yet, and may need to fork for this project to grow.
Comment #2
MGParisi commentedThis is best accomplished with the FLAG's Module. I would recommend you use that. This is outside of the scope of this project, and may break the upgrade path to 6.X! I am going to close this, and would recommend a separate module if this is important.