Moinsen!
Ich versuche momentan einen Mambot umzubauen. Dieser soll wie folgt funktionieren:
1. Im Editor wird {amazon id='12345'} eingegeben werden.
2. Der Bot baut daraus einen Link mit Amazonlogo zur Detailseite des Produkts zusammen.
Momentan habe ich das Problem, dass ich es nichts hinbekomme die ID mit in den Link zu bekommen. Der Bot generiert den Link, setzt aber die Produkt-ID nicht in den Link ein.
Der Link sieht dann so aus:
sollte aber eigentlich so aussehen:Code:<a href="http://www.amazon.de/gp/product/?ie=UTF8&tag=27&linkCode=as2&camp=1638&creative=6742&creativeASIN="<img src="http://g-ec2.images-amazon.com/images/G/03/general/de-logo-153x37.gif" width="153" alt="Amazon.de" height="37" border="0" /></a>Es ist auf den ersten Blick vielleicht etwas verwirrend, aber es gibt zum einen die Variabel $id und die Variabel $ids.Code:<a href="http://www.amazon.de/gp/product/12345?ie=UTF8&tag=amazon-partner-id27&linkCode=as2&camp=1638&creative=6742&creativeASIN="<img src="http://g-ec2.images-amazon.com/images/G/03/general/de-logo-153x37.gif" width="153" alt="Amazon.de" height="37" border="0" /></a>
$id ist die Amazon Partner ID, sie wird aus den Mambot Einstellungen geladen bzw. durch ein default-Value ersetzt.
$ids ist die Produkt-ID, die im Editor als Attribut per id='12345' mitgegeben wird.
Wer da ne zündende Idee hat, warum die Werte nicht mit in den Link eingebaut werden darf mich gerne belehren.PHP-Code:<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mosConfig_absolute_path . '/includes/domit/xml_saxy_lite_parser.php' );
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosAmazon' );
function botMosAmazon( $published, &$row, $mask=0, $page=0 ) {
global $mosConfig_absolute_path;
if (!$published) {
return true;
}
// define the regular expression for the bot
$regex = "#{amazon*(.*?)}#s";
// perform the replacement
$row->text = preg_replace_callback( $regex, 'botMosLink_replacer', $row->text );
return true;
}
/**
* Replaces the matched tags an image
* @param array An array of matches (see preg_match_all)
* @return string
*/
function botMosLink_replacer( &$matches ) {
global $mosConfig_live_site, $database;
$query = "SELECT id FROM #__mambots WHERE element = 'mosamazon' AND folder = 'content'";
$database->setQuery( $query );
$id = $database->loadResult();
$mambot = new mosMambot( $database );
$mambot->load( $id );
$mambotParams =& new mosParameters( $mambot->params );
$AFid = $mambotParams->get( 'AFid' );
$tempalign = $mambotParams->get( 'align' );
$attribs = @SAXY_Lite_Parser::parseAttributes( $matches[1] );
$ids = @$attribs['id'];
$align = @$attribs['align'];
if ($id == "")
{
$id='amazonpartner-id';
}
if ($align == "")
{
$align=$tempalign;
}
return '<a href="http://www.amazon.de/gp/product/'.$ids.'?ie=UTF8&tag='.$id.'&linkCode=as2&camp=1638&creative=6742&creativeASIN='.$ids.'"<img src="http://g-ec2.images-amazon.com/images/G/03/general/de-logo-153x37.gif" width="153" alt="Amazon.de" height="37" border="0" /></a>' ;
}
?>![]()
Gruß - jme


LinkBack URL
About LinkBacks
Zitieren
Lesezeichen