Optional Links to Amazon

cyberswat - June 13, 2007 - 22:58
Project:Amazon associate tools
Version:5.x-1.5
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

We had need to modify this module to disable links back to amazon. This patch adds to the settings page an option to enable/disable the links.

AttachmentSize
amazontools.txt1.9 KB

#1

csc4 - June 25, 2007 - 12:41

+1 for this - it's an excellent enhancement - but could we add one more level of flexibility to it?

A number of people have asked for the module to be able to link to the local book page rather than directly to amazon - could that be added to the options and set accordingly?

#2

cyberswat - June 25, 2007 - 18:30

Sure ... instead of a yes/no radio selection to disable links back to Amazon there are now 3 options:

  1. Images link back to Amazon
  2. Disable image links
  3. Images link to product node
AttachmentSize
amazontools.patch 2.15 KB

#3

cyberswat - June 25, 2007 - 20:24

I ran across this issue http://drupal.org/node/139700 so modified the above patch to also work with the blocks. The global variables affect the behavior uniformly.

AttachmentSize
amazontools2.patch 4.94 KB

#4

csc4 - July 9, 2007 - 10:05

Brilliant - thanks so much.

Had a small problem applying the patch as my module version appears to be later so the line numbers were slightly different

/* $Id: amazon.module,v 1.63.2.7 2007/02/15 02:45:50 prometheus6 Exp $ */

but I put al the changes in (from patch 2) - and selecting link to product node - but the links and the image links don't seem to be changing? I tried importing some new amazon items and they seem unchanged too?

I thought at first that it was that the options were numbered one way in the radios

$form['amazon_link_functionality'] = array(
    '#title' => t('Link Functionality'),
    '#type' => 'radios',
    '#options' => array(t('Images link back to Amazon'),t('Disable image links'),t('Images link to product node')),
    '#default_value' => variable_get('amazon_link_functionality', 0),
  );

Images link back to Amazon - 0

but the opposite way in the Paint_image

switch(variable_get('amazon_link_functionality',0)) {
    case 0:
      $output .= l($image,$node->detailpageurl,array('target'=>'_blank'),null,null,false,true);
      break;
    case 1:
      $output .= $image;
      break;
    case 2:
      if(!$node->nid) {
        $node = db_fetch_object(db_query("SELECT nid,asin from {amazonnode} where asin = '%s'",$selected_book->asin));
      }
      $output .= l($image,'node/'.$node->nid,null,null,null,false,true);
      break;
  }

Images link back to Amazon - 2?

But that didn't seem to fix it so now I'm puzzled! I'm sure it's something obvious!

I think it might be

     if ($node->detailpageurl) {
       $output .= "<a href=\"$node->detailpageurl\" target=\"_blank\">";
@@ -1477,3 +1473,51 @@ function theme_amazon_related_link($node

Shouldn't that be changed to the new style links too? There seem some other occurrences of $node->detailpageurl as well? I tried changing all of them and that seems much more right with the one minor side effect that means there's no amazon link left on the amazon node so that's not quite right either....

I can't help wondering if part f the answer is that there should be a straightforward 'purchase from amazon' or 'view at amazon' button/link on the amazon node? So I as well as changing the other detailurls I added a 'see at amazon' link to my amazon_node page and that seems good?

As my module version seems different from yours I've attached it.

AttachmentSize
amazon.txt 55.79 KB

#5

teachermatt - September 12, 2007 - 23:36

Has anyone had a chance to merge the changes cyberswat made with the changes csc4 made? It would be great to have both options built in!

#6

Riccardo83 - December 11, 2007 - 10:21

yeah that would be great, i just firgured out how to patch but cant apply it cause different versions....

#7

wayland76 - February 14, 2008 - 03:30
Status:needs review» needs work
 
 

Drupal is a registered trademark of Dries Buytaert.