Is there a way to add a new display format, without editing the module itself? What I want is to have the choice of the output only show as a text link to Amazon. Just like the show title as a link one does now, but have it just say "Purchase at Amazon" or something like that. I would rather find a way to do this, if it can be done, by only changing theme folder files, and not the module's.
Comments
Comment #1
wxman commentedI think I figured it out. I added this to my template.php file in my theme called tlt:
Now instead of the book title, the link just shows 'See this item at Amazon'. Of course now I can't use the title text link option. Ideally I would like to add it as another option for the fields display.
Comment #2
Anonymous (not verified) commentedWell, just to add another way for people who want to use this (poorly documented but otherwise very nice) module:
Add a CCK-Field "asin" (don't bother using the Amazon-module field, at least in my case its not working 9/10 times, and yes, I will write a bug report). You can get all the information you want by calling:
in your node-whatever.tpl.php. (assuming only one is is submitted and the field is named asin). It will return you a very nice array of stuff you always wanted to know ;)
Comment #3
wxman commentedThanks. I'll try that too.
Comment #4
drurian commentedtirsales's method didn't work for me.
Comment #5
Anonymous (not verified) commentedWell, perhaps I should go into more detail:
Content-Type and theme
I just added field 'field_asin' (type: text, textfield) to the content-type xyz. In my "node-xyz.tpl.php" I inserted the following code:
Now $amazon contains either null (ASIN is invalid) or the corresponding Amazon-information, one example of a random book is attached.
I've printed the array using
Now to e.g. print the Title from Amazon:
etc:
Now, an example code to print the content of the node (in your node-xyz.tpl.php) with the cover-image and some basic-information:
Validation
As my content-type is only worth something, if Amazon-Content could be collected, I've added a validator (using http://drupal.org/project/validation_api ) using a PHP-validator:
but this is optional. The check fails if a) the ASIN is invalid (no Amazon-content could be retrieved) and b) the ASIN is not '---'. If the
check fails, "preview" or "save" on a node fails with an error-message.
Nodetitle
I'm using http://drupal.org/project/auto_nodetitle to set the node-title to something like "Author - Book", but this is optional too:
System
I'm using Drupal-6.10, Content 6.x-2.1, Amazon API 6.x-1.0-beta5 and Validation API 6.x-1.0 and Automatic Nodetitle 6.x-1.1
I do believe that there are better ways to display this information, but this approach works (for me) and allows me to adjust what information is visible. In fact it allows to integrate with Validation API etc to avoid potential misspellings or problems. I did not check whether this uses the caching mechanism of the Amazon API, but I believe so.
Comment #6
drurian commentedThanks, tirsales, for spelling it out for the dummies :)
Did you think about adding it to the handbook? I think it will be very helpful indeed.
Comment #7
Anonymous (not verified) commentedI didn't even know that the Amazon API has a handbook page/area?
Comment #8
wxman commentedI just wanted to add that tirsales method has worked great for me. I even customized the tpl file so the medium book cover shows, and if you click it, Lightbox2 kicks in showing the Amazon large cover.
Comment #9
drurian commentedI think I figured out how to change display of inline items using input format. It's in the filter.module, but not documented.
Obviously, if you use fields you can modify default template for specific field.
Comment #10
Anonymous (not verified) commentedThat's very nice for you drupal librarian - could you elaborate on your method?
Comment #11
drurian commentedSure, that's what I do
* Note I'm talking about Amazon inline filter, not Amazon CCK fields.
Basically, amazon module uses one theme_amazon_item function and different variations of it.
In the case of filter.module it will theme the output depending on what the third word in the input string is.
If you use [amazon ASIN] or [amazon ASIN inline] it will use the default theme_amazon_inline_item function (note that in Amazon media module DVD, software and videogames have their own additional inline theme formatting, but not books). If the third word is 'details' or 'thumbnail' it will use amazon-item-details or amazon-item-thumbnail templates included in the module (again, amazon media module will use its own templates). If it can't match the third word, it will simply use amazon-item template.
Now, to implement custom input format theming, create amazon-item-example template in your theme directory and then you can use [amazon ASIN example] format in your nodes.
For example, if you want to print the large image, create amazon-item-largeimage.tp.php, add
<?php print $largeimage; ?>(or whatever you want)Then [amazon ASIN largeimage] will call this template.
Don't forget to copy amazon-item to your theme directory, or it's going to use the module's templates instead.
Comment #12
rfayExcellent work in this thread.
The handbook page for Amazon Module now exists, and if you folks can help add to it, that would be much appreciated.
http://drupal.org/node/595464
Comment #14
rfayThere are an enormous number of new filter options available to you as of tomorrow's dev release, soon to be a beta. See the docs at http://drupal.org/node/595464 and this issue: http://drupal.org/node/598588