Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The module description says 'basic token support', but no tokens show up in the list of tokens available to Automatic Node Title.
I'd like to be able to simply input an ASIN number and have the generated node use the Title from amazon. How can you use tokens?
Is this possible?
Comment | File | Size | Author |
---|---|---|---|
#37 | Book - ho-jo-east.com_1264283692644.png | 38.21 KB | hojoeast |
#37 | Book - ho-jo-east.com_1264283743023.png | 39.61 KB | hojoeast |
#34 | Screenshot-Amazon API | Edward Andrews - Mozilla Firefox.png | 204.35 KB | Edward Andrews |
#17 | Picture 3.png | 37.7 KB | sean porter |
#17 | Picture 2.png | 45.3 KB | sean porter |
Comments
Comment #1
arghman CreditAttribution: arghman commentedMe too! I'd love to use the various amazon metadata that is available, but can't figure out how.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedA fast solution is something like the following (assuming that field_asin contains the ASIN, it is a single required value and you want the list of authors followed by the title) entered into the "automatic title generation" field.
Comment #3
gmak CreditAttribution: gmak commentedtirsales,
I'm interested in your code, but where do I put it?
Thanks
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedThis code uses Auto Nodetitle to generate the nodetitle automatically. Auto nodetitle provides a field "Automatic title generation" on each "edit content-type settings"-page (e.g. admin/content/node-type/amazontype).
Please remember to check "evaluate PHP"
Comment #5
saepl CreditAttribution: saepl commentedI just tried the auto nodetitle trick and had no success. The title only has a dash ('-') in it.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedCould you paste your code and ASIN? Even better: A screenshot of your page.
Comment #7
saepl CreditAttribution: saepl commentedAttached is a screen shot and here is the code I am using. I changed it a bit to add the word "Book Review: " at the beginning of the title.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedI do apologize for not stating clearly what I meant - I meant a screenshot of the content-type settings page (the page where you add your autotitle). Is your field named "asin" internally and did you apply the patch needed to parse ASINs with a leading 0 (looks alike seeing the cover, but still want to ask).
Comment #9
saepl CreditAttribution: saepl commentedSorry. Here are three more screen shots they should have what you need (I hope!)
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedUse field_booktitle instead of field_asin:
Comment #11
saepl CreditAttribution: saepl commentedHmm...very disappointing but it doesn't work :( I even tried deleting my original field and created a new one called "field_asin" but I get the same thing, a title with just a dash in it.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedWell - what title are you now using for the field? and which title is presented in the autotitle-form?
--edit: And to use the above snippet, the field should be a textfield, no Amazon-field.
Comment #13
saepl CreditAttribution: saepl commentedI created a new textfield called "asin" so I am using "field_asin" in the autotitle-form.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedSome corrections (assuming the field is called (field_)name and is a SIMPLE textfield, not an amazon textfield):
assuming its an AMAZON textfield (Type: Amazon, element: Textfield)
Please regard: The difference lies in $node->field_name[0]['asin'] (AMAZON textfield) vs $node->field_name[0]['value] (normal textfield).
Comment #15
saepl CreditAttribution: saepl commentedThanks tirsales. It works now! I was using an amazon text field.
Comment #16
saepl CreditAttribution: saepl commentedI am resurrecting this thread :)
I noticed that when I use this code in my auto title that it only generates the titles for books but not for movies or cds
Comment #17
sean porter CreditAttribution: sean porter commentedTrying to see what I'm doing wrong, I'd love to get auto nodetitle to work this way. I'm getting nothing to show up when I rebuild my nodetitles.
I've attached screengrabs of my content-type settings
any help would be greatly appreciated!
Comment #18
saepl CreditAttribution: saepl commentedDo you have evaluate php in patterns turned on? http://drupal.org/files/issues/Picture%204_75.png
Comment #19
sean porter CreditAttribution: sean porter commentedYes, I do, sorry that wasn't included the picture.
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commented@saepl:
Print the list of available keys - its very likely that the "author"-key is only available for *books, not for music or dvds.
watchdog('Amazon Test','
');
should print the complete $amazon-variable to the watchdog ( admin/reports/dblog ). Have a look at it and decide, which fields to use :)
Maybe you need something like
if ( array_key_exists('author',$amazon) ) {
// use $amazon['author'];
} else {
// use $amazon['producer'] or whatever
}
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commented@sean porter:
You could change your code to the following:
This should log the content of $amazon, then you can verify whether you can find any item at all :)
Comment #22
saepl CreditAttribution: saepl commentedWhen I add a book I get the $amazon variable if I choose a CD (I choose a beatles cd) I get empty - no data at all :(
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedDo you have the correct ASIN?
Comment #24
saepl CreditAttribution: saepl commentedI assume I have the correct ASIN because the cd cover, artist, etc is put into my node
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedWell, print or watchdog $_amazon and $asin - it's quite possible that CDs use a different data structure.
Comment #26
saepl CreditAttribution: saepl commentedOk. I solved my problem.
When you enter an asin that relates to a cd or movie the asin value listed on amazon's website is all uppercase but then it gets converted to all lower case in $asin so you have to make $asin uppercase as per:
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks for the info :)
Comment #28
sean porter CreditAttribution: sean porter commented@tirsales
awesome, this worked for me. I'm not sure if something was wrong with my code or if it was because I didn't have the php evaluation module enabled...
Comment #29
gmak CreditAttribution: gmak commentedThis:
was working fine for me, but suddenly it has stopped working. My tests with the module (/admin/settings/amazon/test) work fine and retrieve all the relevant info.
Any idea why this would suddenly stop getting the title and populating the node title?
Comment #30
gmak CreditAttribution: gmak commentedI've found something odd. There seem to be some ASIN numbers that don't work. I can't see why this would be, but with a few numbers a title doesn't get retrieved. If I plug the ASIN into the testing page it gets a title, but not with the PHP code for the auto node title.
Any suggestions?
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedTry searching if a previous issue exists (I remember a previous issue regarding non-working ASIN) - otherwise file a bug. And/or try to get some more debug output (e.g. printing $asin via print_r)
Comment #32
rfayNote that an ASIN is not a guarantee that the item will always be available from Amazon. It's quite normal that an ASIN disappears from Amazon, meaning that it's orphaned in your node on Drupal.
Marking this 'fixed', but I will add token support as a feature request in the D7 port list.
Comment #34
Edward Andrews CreditAttribution: Edward Andrews commentedTwo questions related to this.
I'm using the code in post #14 - the version for the amazon field type. It works just as expected. EXCEPT there is at least one ASIN that doesn't work. It finds the information for the post, but the title doesn't work. I'm using amazon.co.uk and the particular ASIN is 193339742X
Using the amazon module test page with this ASIN works as expected, picture attached, but the title doesn't work at all.
Any thoughts?
Second question - is it possible to modify the code to use the 13 figure ISBN number as the input?
Thanks.
Comment #35
rfay@Edward Andrews: Please use the current version, if you're not already.
If you're having trouble doing a test on a specific ASIN, please (with the current version) do it and then follow the link to the error log and report the results.
The current version of Amazon module does ISBN-13. See the project page
Comment #36
antiorario CreditAttribution: antiorario commentedsubscribing
Comment #37
hojoeast CreditAttribution: hojoeast commentedI'm trying to utilize the snippet in comment 14. My field name is aisbn. The snippet I'm using is:
I've tried numerous variations, but, all I ever get is Book Review: and no title or author. I've tried several ISBN numbers. The content is displayed properly with the appropriate book. But, the node title always comes out as just Book Review:.
I've attached a snapshot of my field list and also the automatic title section. It must be something simple that I'm doing wrong, but, I just can't spot it. Any help would be greatly appreciated. Thx.
Comment #38
hojoeast CreditAttribution: hojoeast commentedPerhaps someone might be able to point me in the right direction. I've done some further work with this snippet. I've determined that it works fine for ten digit ISBN numbers, with or without leading zeroes. However, it does not work for 10 or 13 digit ISBN numbers with embedded hyphens. Also, it does not work at all for 13 digit ISBN numbers. I'm using version 6.x-1.0-rc3 of the Amazon module. My content works fine. The only thing that is a problem is this issue with Auto Nodetitles. Thanks in advance.
Comment #39
rfay@hojoeast, the current version does fine with ISBN 13-digit ISBN numbers, and it accepts embedded dashes.
If you have an example or a specific problem, please open another issue. I'll do my best to resove it.
Thanks,
-Randy
Comment #41
CarbonPig CreditAttribution: CarbonPig commentedsubscribe
Comment #42
cwithout CreditAttribution: cwithout commentedFor anyone else who doesn't want to turn on PHP filter, you can try the following in a custom module to get a token to use for autotitle.
Comment #43
rfayCorrect code for this use case (auto_nodetitle with an ASIN CCK field) is in #991994-3: Using Auto NodeTitle with an Amazon CCK field to generate title (and using ISBN-13). The code in this issue has some oddities (unneeded _amazon_clean_type(), etc.)
Comment #44
BeaPower CreditAttribution: BeaPower commentedHow can I add the ISBN to the title for books?
Comment #45
rfayIn the case of books, a 10-digit ASIN is the ISBN number....
This code will work assuming the ASIN field is named field_isbn. Note that the ISBN is not formatted.
You can access any of the values shown on admin/settings/amazon/test.
Comment #46
ambereyes CreditAttribution: ambereyes commented#42 worked for me, thanks.
This token and others should be added to the module.
Comment #47
rfayI actually never have figured out how the (existing) token support in ASIN module is useful, since it's not clear which field in a multivalued field creates the token. #42 assumes in advance that it knows the name and number of the specific CCK field on the page to use. General code does not know that.
Setting this to "fixed", but if somebody wants to make a specific proposal or provide a patch, please open a new issue.
Comment #49
cwithout CreditAttribution: cwithout commentedAnyone who needs this functionality, please go to #1043030: D6: Improved token support (especially for Automatic Node Titles) and test the patch. Post any issues you encounter with the patch there.
(Make sure you download the latest one. Don't use the first one posted. It had mistakes.)