Extension talk:AmazonPlus

From mediawiki.org
Latest comment: 13 years ago by Skizzerz in topic Multiple Authors

Using templates[edit]

Is the syntax <amazon id="{{{1}}}">blablabla</amazon> correct ? It doesn't seem to work in my templates... Thanks ! --Alagache 04:31, 19 February 2009 (UTC)Reply

Fixed in 0.4.0. --Skizzerz 21:25, 19 February 2009 (UTC)Reply
Seems to be an issue in 0.5.2. See example on my wiki. --Short Circuit 05:15, 24 January 2010 (UTC)Reply
I think that the reason is that MediaWiki won't let you use template variables inside an xml tag (that is, for example, as an attribute): the solution is to use the {{#tag:}} parser function. -- Chris Hennes 21:30, 30 January 2011 (UTC)Reply

Fix[edit]

I fixed it, at least as far as MediaWiki 1.16 is concerned. (The relevant changes for earlier versions of MediaWiki can be induced from Manual:Tag extensions#How do I render wikitext in my extension?. Find the efAmazonPlusRender function in AmazonPlus.php. Change the function declaration from:

function efAmazonPlusRender( $input, $args, $parser) {

to

function efAmazonPlusRender( $input, $args, $parser, $frame) {

Now find the lines:

        # Parse out template parameters only before getting setting up the class so {{{1}}} and the like work
        $input = $parser->replaceVariables( $input, false, true );
        foreach( $args as $key => $arg ) {
                $args[$key] = $parser->replaceVariables( $arg, false, true );

Replace them with:

        # Parse out template parameters only before getting setting up the class so {{{1}}} and the like work
        $input = $parser->recursiveTagParse( $input , $frame);
        foreach( $args as $key => $arg ) {
                $args[$key] = $parser->recursiveTagParse( $args[$key], $frame );

That seems to be working for me. --Short Circuit 21:06, 24 October 2010 (UTC)Reply

Fatal error Line 27 php[edit]

I just installed this extension, and got an error message.

Fatal error: Call to undefined function wfinigetbool() in /home/debatrix/public_html/extensions/AmazonPlus/AmazonPlus.php on line
27

Has anyone seen this, how do I fix it? --Jake4d 01:50, 6 June 2009 (UTC) (using v1.14)Reply

I think I see what I need to do, here, but I cannot find the php.ini file, and I don't know how to allow Mediawiki to use the "ini_set() function" can anyone help? --Jake4d 02:18, 6 June 2009 (UTC)Reply
Actually, you need to be running mediawiki version 1.12 or later. The 1.11 on the extension page was a typo and has now been fixed :) --Skizzerz 16:06, 7 June 2009 (UTC)Reply
I am running 1.14 and still can't get it to work. Does it only work with 1.12? --Jake4d 23:35, 7 June 2009 (UTC)Reply
Are you installing it according to the instructions listed on the extension page? Note that this is a part of mediawiki, so accessing the AmazonPlus.php file directly in your browser won't work, you need to use the <amazon> tag in the wiki itself to use the extension. --Skizzerz 00:00, 8 June 2009 (UTC)Reply
Yes, I am installing it by the instructions, but when I "include" it in my localsettings.php I get a fatel error on the wiki, so I have been unable to try using the <amazon> tag. --Jake4d 01:52, 8 June 2009 (UTC)Reply

Try re-downloading the files for 1.14 then, since there is something messed up with your wiki. --Skizzerz 13:51, 8 June 2009 (UTC)Reply

I will try again tonight. --Jake4d 00:22, 9 June 2009 (UTC)Reply
Issue fixed in 0.5.2 --Skizzerz 17:27, 28 October 2009 (UTC)Reply

Can't Connect to Amazon Webservices[edit]

I've tried everything I can think of - SimpleXML installed, AWS keys are right, but still get: Error: Could not retrieve data from Amazon!

No idea what the issue is, perhaps amazon changed their URL for retrieval?

That is likely, Amazon likes to change things up every now and again. I'll look into this issue, but I cannot guarantee a speedy reply. --Skizzerz 04:11, 6 July 2010 (UTC)Reply
I've found this can happen if you're using Adblock. It depends on which filter set you use, of course. --Short Circuit 04:45, 6 July 2010 (UTC)Reply
I am also having this problem, and I'm not using Adblock

Internal and External links[edit]

I've noticed that I can't put any type of link within the <amazon> tags. If I do a link like, Google, it just shows the html to the link, and if I try to link to a page on the wiki itself, like User:Smile Lee it shows nothing. Is there a way to fix it? Smile Lee 01:58, 9 December 2010 (UTC)Reply

Multiple Authors[edit]

Out of the box this extension will only return the first author of a multiple-author work. To fix this, you need to insert the following code (or something like it) in the getResult() function:

                 foreach ( $item->ItemLinks->ItemLink as $link ) {
                        $links[str_replace( ' ', '', $link->Description )] = $link->URL;
                }
  +               $authorArray = array ();
  +               foreach ($attr->children() as $key => $value) {
  +                       if ($key == "Author") {
  +                               $authorArray[] = $value;
  +                       }
  +               }
  +               $authorList = implode(",",$authorArray);
                $replace = array(
                        /* IMAGES */
                        'largeimage'      => $imageset->LargeImage->URL,

Then below, where it constructs the $replace array, change

'author' => $attr->Author

to

'author' => $authorList

This will give you a comma-separated list of authors that you can use as input to the #arraymap parser function. Note that this may not be the best way of doing this, but it works. -- Chris Hennes 20:40, 30 January 2011 (UTC)Reply

Thanks for the patch, there are a few things that need revising in it (mainly that hardcoding commas is bad since different languages use different list-item delimiters), but I'll definitely apply this in the near future! --Skizzerz 19:44, 1 February 2011 (UTC)Reply