you're probably going to be swamped this weekend wiht the new Amazon field. but i thought i would ask for this feature, as it might be easier to do while you're in there.

the "We Recommed" block note

would it be possibl to have an "option" is setting that would allow the node to pull from the current list of books randomly like it is already doing - which is cool and saves a lot of wrok

but to also be able to pull from a different "esspecailly created list" (seperate list) just for that node

thanks for considering

Comments

Prometheus6’s picture

Project: Amazon search » Amazon associate tools
Version: 4.6.x-1.x-dev » master

Not to be rude, but I actually don't do feature requests on GPL stuff for free.

Bug fixes, even help with nasty install problems I will do.

green monkey’s picture

that makes sense, you would probably be working your tail off everyday, doing freebies. I didn't find your statement rude at all.

boris mann’s picture

Hey Prometheus...it's fine if *you* don't want to do it, but someone else might like to. Can we leave this open so that people can find it? And if/when we get a status of "bounty", you might be interested in implementing it.

Prometheus6’s picture

At that point, I guess there's a couple old feature requests that could be reopened...

solipsist’s picture

Prom: I understand your point of view but he asked a polite question, and I'm sure he understands that people can't do stuff for free all the time.

I'd like to see a similar feature, maybe the possibility of using flexinodes a custom field for for storing ASINs or keywords related to the node which the amazon module can use to pull data from amazon.com or using data from local amazon-nodes.

Anyway, I love this module and I'd gladly donate some money by PayPal or any other means.

Prometheus6’s picture

The particular feature isn't useful to me, but I can be bribed. The easy way is to modify the module so that the ASINs in the related products field drives a block instead of producing a list of links at the bottom of the node. Second easiest is to add another field. Third is to let Amazon pick up to ten books based on the content of $node->body (I can't guarantee the quality of topic match).

The other thing is, such a module would be for version 4.6 OR 4.7.

solipsist’s picture

Well, I made this little modification myself, it checks whether the node has any ASINs associated with it, if so it loads one of them randomly and shows in the block, otherwise it pulls one randomly from the database. My original idea was to add a Product Keywords field to every node type which I would use with a SELECT ... LIKE query to find matching Amazon items, it would be more flexible but failing to figure out how to modify the nodeapi hooks and stuff (I have only been using Drupal for a short time) I went with this somewhat simple implementation. Hope it works for you too. Around line 777, replace the existing code with:

      if ( arg(0) == 'node' && is_numeric(arg(1)) ) { //loads the $node
         $node = node_load( array('nid' => arg(1)) );
      }

      $amazon_items = explode(',',$node->ASIN); //creates an array from $node->ASIN (the list of ASINs for related items)
      if ((strlen($amazon_items[0]) > 5)) { //if it is real array
            $max_record = count($amazon_items);
            // generate a random number between 1 and the count
            $random = rand(0, $max_record - 1);
            // get that one record
            $selected_book = db_fetch_object(db_query( "SELECT * from {amazonitem} WHERE ASIN = '" . $amazon_items[$random] . "'" ));
    } else { //this is the old code more or less
            $amazon_counter = db_fetch_object(db_query("SELECT COUNT(ASIN) AS count FROM {amazonitem}"));
            $max_record = $amazon_counter->count;
            $random = rand(0, $max_record - 1);
            $selected_book = db_fetch_object(db_query("SELECT * from {amazonitem} LIMIT $random,1"));
    }

Credits goes to Morbus Iff who helped me figure out how to load the node. The code isn't pretty, especially

$amazon_items = explode(',',$node->ASIN);
if ((strlen($amazon_items[0]) > 5)) {

so I'm sure Prometheus6 could come up with something nicer. You're welcome to commit it if you like.

green monkey’s picture

you guys are the best :-)

can't wait to try it out

much thanks

Prometheus6’s picture

This is the block that doesn't show up on the blog page, isn't it?

      if ( arg(0) == 'node' && is_numeric(arg(1)) ) { //loads the $node
         $node = node_load( array('nid' => arg(1)) );
      }

On the user blog page, where does "node" show up in the url? Also

      $amazon_items = explode(',',$node->ASIN); //creates an array from $node->ASIN (the list of ASINs for related items)
      if ((strlen($amazon_items[0]) > 5)) { //if it is real array
            // generate a random number between 1 and the count
            $random = rand(0, $max_record - 1);
            // get that one record
            $selected_book = db_fetch_object(db_query( "SELECT * from {amazonitem} WHERE ASIN = '" . $amazon_items[$random] . "'" ));

This ain't working. When you load the node, you don't just get an array of ASINs. You get an array of matching amazonitem records. So once you do node_load(), count the items in $node->amazonnode_data, pick one at random and stuff it into the block.

And please, do this:

if (is_array($node->amazonnode_data))

instead of this

if (strlen($node->amazonnode_data) > 5)

Now, having done that (because you've been nice) I need to yell at you. You really can't come to me for support of code you've modified because I have no idea what you've done.

Prometheus6’s picture

Status: Active » Closed (fixed)