This issue is related to #392524: Add token support for automatic node title in that I'm trying to use auto_nodetitle and populate the node title with Amazon.com data.

The specific issue is that if a user enters a 13 digit ISBN/EAN or an ISBN with hyphens in it the node title will not populate upon the initial save. If the user returns to the node edit page, the ASIN field is formatted correctly and will then populate the node title as expected when saving again.

I'm using a variation of the code from the issue mentioned above in the Automatic title generation field:

  $asin = strtoupper(_amazon_clean_type($node->field_review_asin[0]['asin']));
  $_amazon = amazon_item_lookup($asin);
  $amazon = $_amazon[$asin];
  print $amazon['title'];

Everything works fine if a properly formatted ASIN is entered.

My suspicion is that something in the Amazon module is converting any improperly formatted input and retrieving the Amazon.com data AFTER auto_nodetitle looks for the item title to use.

I've tried installing Util and using Module Weights to move Automatic Nodetitles down in the list, but it seems to have no effect.

Is this where I should seek support for this issue or should I post in the Automatic Nodetitles issue queue?

Thanks.

Comments

rfay’s picture

Please provide the exact example that gives you trouble and give me the script I should run through to recreate it.

Thanks,
-Randy

tommyk’s picture

Thanks for the offer to help.

Using a fresh Drupal 6 install, I turned on:

Amazon API
Amazon field
Amazon media
Amazon search (not sure if needed)
Content (CCK)
Content Permissions (maybe unnecessary for this test)
Text (maybe unnecessary for this test)
Search (core) (not sure if needed)
Automatic Nodetitles

1. created content type Review (review)
2. added CCK field "ISBN or ASIN" (field_review_asin) of type Amazon item with Widget type of ASIN or ISBN Text field
3. pasted the following code into Automatic title generation Pattern for the title field

    $asin = strtoupper(_amazon_clean_type($node->field_review_asin[0]['asin']));
    $_amazon = amazon_item_lookup($asin);
    $amazon = $_amazon[$asin];
    print $amazon['title'];

4. checked Evaluate PHP in pattern box
5. create content Review
6. paste 978-0470429037 or 978-1430209898 or any other 13 digit ISBN into the field
7. save node
8. no title appears
9. edit node
10. do nothing (EAN has been converted to 10 digit in the field)
11. save node
12. title appears
13. test with 10 digit ISBN
14. create content Review
15. paste 1430209895 into field
16. save node
17. title appears

Hope this is what you need to make sure I'm not crazy.

=)

rfay’s picture

Title: 13 digit ISBN/EAN to ASIN conversion process timing » Using Auto NodeTitle with an Amazon CCK field to generate title (and using ISBN-13)

I think this will work for you for making a title from a field. Here I'm using a field named field_isbn. You'll have to change yours accordingly, and change the default title, etc.

<?php
    if (!empty($node->field_isbn[0]['asin'])) {
      $asin = $node->field_isbn[0]['asin'];    // Get the asin from the field
      $asin = amazon_convert_to_asin($asin);  // Turn ISBN-13, etc into ASIN. Needed only if ISBNs are allowed
      // dsm($asin, 'found asin');
      $items = amazon_item_lookup($asin);   // Get the full data.
      // dsm($items, '$items');
      if (count($items)) {
        print $items[$asin]['title'];
        return;
      }
    }
    print t("No Amazon item can be used to generate title, so this is the bogus title (node @nid)", array('@nid' => $node->nid));
?>
mudgil.gaurav’s picture

Priority: Normal » Critical

Hi

Thanks for the information provided above.Can you please brief me in which file i need to
use the above code.To get the book title,author,price etc.

Please elaborate more.

Thanks

rfay’s picture

#2 contains the basics including a step-by-step. This is a way to use the auto_nodetitle module to set the title based on an ASIN item.

mudgil.gaurav’s picture

Hi,

Thanks for your quick response.Yes i gone through #2. But after step 3 i.e. pattern generation and onward i am not able to locate where to set the pattern.

According to #2 i created a field fld_isbn and fld_title.And for the fld_title set type data to store to "Node Reference" and form element to edit the data to "Automatic text field".

My requirement is i want to allow the user to add the books.When user fills the ISBN number then if the ISBN number is valid then other fields i.e. author,title,price should be auto populated in the corresponding
text fields.

Any help or suggestion would be greatly appriciated.

Thanks
Gaurav

rfay’s picture

Priority: Critical » Normal

I think you're doing something beyond what auto_nodetitle can do - it can only set the title. But you can *theme* the other fields quite easily.

willvincent’s picture

Status: Active » Closed (works as designed)