TinyPortal

Development => Block Codes => Topic started by: nite0859 on February 28, 2007, 04:46:03 AM

Title: BBC :: Linking keywords inside a post to Amazon.com searches ..
Post by: nite0859 on February 28, 2007, 04:46:03 AM
Searching Amazon from a keyword inside of a regular post.

DEMO :: here (http://forum.midessa.net/forum-code-testing/embedding-amazon-search-usa-into-a-simple-machines-forum-t1935.0.html).

** Backup your files in case this modification fails for you.

For Amazon.COM, Amazon.CA, Amazon.CO.UK, and AMAZON.DE
Add the Amazon BBC Image Button to :: /Themes/default/images/bbc/amazon.gif
Be sure that the amazon image name is lowercase.
BBC Button Image (23px x 22px) :: (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fforum.midessa.net%2FThemes%2Fdefault%2Fimages%2Fbbc%2Famazon.gif&hash=2c40b62bf78884f909bc62526dbed0f9e15de8fd)
***
Notice :: When examining the code that I have listed, be aware that I have included much of the SURROUNDING code as well. This is so that finding the specific areas for code insertion is made easier. The specific code relevant to enabling the amazon searching will be sectioned off using // with relevant descriptions as to where the amazon searching code begins and where the amazon searching code ends for this particular modification.
***
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpermian-mall.midessa.net%2Fimages%2FUSA-30x30.gif&hash=9116917232aa108b55901fb906a76a0f2c68cd92)  For Amazon.COM searches
File to be edited :: /Sources/Subs.php
Where to be added :: Pay attention to where the // Begin and // End occur.

array(
'tag' => 'html',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'disabled_content' => '$1',
),
// Beginning of Amazon Search Code ..
array(
'tag' => 'amazon',
'type' => 'unparsed_content',
'content' => '<a href="http://www.amazon.com/gp/search?index=blended&_encoding=UTF8&tag=amazon-xml-20&camp=211041&creative=374001&linkCode=qs1&adid=0RRMYTA7XJMF27CGEZ7A&keywords=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">$1</span>',
),
array(
'tag' => 'amazon',
'type' => 'unparsed_equals',
'before' => '<a href="http://www.amazon.com/gp/search?index=blended&_encoding=UTF8&tag=amazon-xml-20&camp=211041&creative=374001&linkCode=qs1&adid=0RRMYTA7XJMF27CGEZ7A&keywords=$1" target="_blank">',
                'after' => '</a>',
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
                'disabled_after' => ' ($1)</span>',
),
// End of Amazon Search Code ..
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpermian-mall.midessa.net%2Fimages%2FDE-30x30.gif&hash=51ce080e189b9f6f8f4365572cb4168678737ac6)  For Amazon.DE searches
File to be edited :: /Sources/Subs.php
Where to be added :: Pay attention to where the // Begin and // End occur.

array(
'tag' => 'html',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'disabled_content' => '$1',
),
// Beginning of Amazon Search Code ..
array(
'tag' => 'amazon',
'type' => 'unparsed_content',
'content' => '<a href="http://www.amazon.de/gp/search?index=blended&_encoding=UTF8&tag=amazon-search-21&camp=1874&creative=7026&linkCode=qs1&adid=1YP1PXQYH77Q7Z3CVEND&keywords=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">$1</span>',
),
array(
'tag' => 'amazon',
'type' => 'unparsed_equals',
'before' => '<a href="http://www.amazon.de/gp/search?index=blended&_encoding=UTF8&tag=amazon-search-21&camp=1874&creative=7026&linkCode=qs1&adid=1YP1PXQYH77Q7Z3CVEND&keywords=$1" target="_blank">',
                'after' => '</a>',
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
                'disabled_after' => ' ($1)</span>',
),
// End of Amazon Search Code ..
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpermian-mall.midessa.net%2Fimages%2FUK-30x30.gif&hash=07b2f28ae82ea3ba5ecc6816e9d7e681755d359d)  For Amazon.CO.UK searches
File to be edited :: /Sources/Subs.php
Where to be added :: Pay attention to where the // Begin and // End occur.

array(
'tag' => 'html',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'disabled_content' => '$1',
),
// Beginning of Amazon Search Code ..
array(
'tag' => 'amazon',
'type' => 'unparsed_content',
'content' => '<a href="http://www.amazon.co.uk/gp/search?index=blended&_encoding=UTF8&tag=amazon-xml-21&camp=1878&creative=7034&linkCode=qs1&adid=0CNVBQZ39V2DE8PGE4PH&keywords=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">$1</span>',
),
array(
'tag' => 'amazon',
'type' => 'unparsed_equals',
'before' => '<a href="http://www.amazon.co.uk/gp/search?index=blended&_encoding=UTF8&tag=amazon-xml-21&camp=1878&creative=7034&linkCode=qs1&adid=0CNVBQZ39V2DE8PGE4PH&keywords=$1" target="_blank">',
                'after' => '</a>',
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
                'disabled_after' => ' ($1)</span>',
),
// End of Amazon Search Code ..
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpermian-mall.midessa.net%2Fimages%2FCA-30x30.gif&hash=e006159569184167945d9bc57ce2ea1862d1d5c2)  For Amazon.CA searches
File to be edited :: /Sources/Subs.php
Where to be added :: Pay attention to where the // Begin and // End occur.

array(
'tag' => 'html',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'disabled_content' => '$1',
),
// Beginning of Amazon Search Code ..
array(
'tag' => 'amazon',
'type' => 'unparsed_content',
'content' => '<a href="http://www.amazon.ca/gp/search?index=blended&_encoding=UTF8&tag=amazon-search-20&camp=211045&creative=374009&linkCode=qs1&adid=1M7F3E5QVSFP2W9NMEZZ&keywords=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">$1</span>',
),
array(
'tag' => 'amazon',
'type' => 'unparsed_equals',
'before' => '<a href="http://www.amazon.ca/gp/search?index=blended&_encoding=UTF8&tag=amazon-search-20&camp=211045&creative=374009&linkCode=qs1&adid=1M7F3E5QVSFP2W9NMEZZ&keywords=$1" target="_blank">',
                'after' => '</a>',
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
                'disabled_after' => ' ($1)</span>',
),
// End of Amazon Search Code ..
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


For Amazon.COM, Amazon.CA, Amazon.CO.UK, and AMAZON.DE
File to be edited :: /Themes/default/Post.template.php
Where to be added :: Pay attention to where the // Begin and // End occur.
Note :: This code actually makes the BBC button appear.

$context['bbc_tags'][] = array(
'flash' => array('code' => 'flash', 'before' => '[flash=200,200]', 'after' => '[/flash]', 'description' => $txt[433]),
// Begin Amazon Search Code ..
'amazon' => array('code' => 'amazon', 'before' => '[amazon]', 'after' => '[/amazon]', 'description' => $txt['amazon_bbcode_desc']),
// End Amazon Search Code ..
'stream' => array('code' => 'stream', 'before' => '[stream=475,325]', 'after' => '[/stream]', 'description' => $txt['stream']),
'real' => array('code' => 'real', 'before' => '[real=475,325]', 'after' => '[/real]', 'description' => $txt['real']),
'quick' => array('code' => 'quick', 'before' => '[quick=475,325]', 'after' => '[/quick]', 'description' => $txt['quick']),
'gv' => array('code' => 'gv', 'before' => '[gv=475,325]', 'after' => '[/gv]', 'description' => $txt['gv']),
'yt' => array('code' => 'yt', 'before' => '[yt=425,350]', 'after' => '[/yt]', 'description' => $txt['yt']),
'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt[435]),
'url' => array('code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt[257]),
'email' => array('code' => 'email', 'before' => '[email]', 'after' => '[/email]', 'description' => $txt[258]),
'ftp' => array('code' => 'ftp', 'before' => '[ftp]', 'after' => '[/ftp]', 'description' => $txt[434]),
array(),
'table' => array('code' => 'table', 'before' => '[table]', 'after' => '[/table]', 'description' => $txt[436]),
'tr' => array('code' => 'td', 'before' => '[tr]', 'after' => '[/tr]', 'description' => $txt[449]),
'td' => array('code' => 'td', 'before' => '[td]', 'after' => '[/td]', 'description' => $txt[437]),



For Amazon.COM, Amazon.CA, Amazon.CO.UK, and AMAZON.DE
File to be edited :: /Themes/default/languages/Modifications.english.php
Where to be added :: Add these lines and before the .PHP file closes out, i.e. before the ?> symbol.
Note :: In the code below, change the (USA) to (DE) for German searches. Change the (USA) to (UK) for United Kingdom searches. Change the (USA) to (CA) for Canadian searches.

// Begin Amazon Search Code ..
$txt['amazon_bbcode_desc'] = 'Amazon Search (USA)';
// End Amazon Search Code ..
Title: Re: BBC :: Linking keywords inside a post to Amazon.com searches ..
Post by: RoarinRow on February 28, 2007, 03:17:21 PM
Cool snippet.  I shop Amazon.com all the time   :up:
Title: Re: BBC :: Linking keywords inside a post to Amazon.com searches ..
Post by: nite0859 on March 01, 2007, 01:58:45 PM
Hey, thanks.