Php in .tpl datein

Hallo Forum, mich würde interessieren, wie ich in einem TPL File Php nutzen kann? Geht das irgendwie? Danke für eure Antworten :slight_smile: Stephan

[quote=“cu-viper”]Hallo Forum, mich würde interessieren, wie ich in einem TPL File Php nutzen kann? Geht das irgendwie? Danke für eure Antworten :slight_smile: Stephan[/quote] Null Problemo! Einfach in “{php}{/php}”-Tags einschließen. Bei umfangreicherem PHP sollte man besser nur eine PHP-Datei "include"n, um die Lesbarkeit des Smarty-Codes nicht zu zerstören.

Ich mag den Shop immer mehr :slight_smile: Danke :slight_smile:

Kann es sein, dass das in SW 4 nicht mehr geht? Bekomme einen Fatal Error zurück. Was wäre denn in Shopware 4 der korrekte Code um PHP-Files zu includen? Fehlermeldung: Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/frontend/index/left.tpl" on line 4 "{php}" unknown tag "php"' in /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templatecompilerbase.php:627 Stack trace: #0 /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templatecompilerbase.php(406): Smarty\_Internal\_TemplateCompilerBase-\>trigger\_template\_error('unknown tag "ph...', 4) #1 /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templateparser.php(2418): Smarty\_Internal\_TemplateCompilerBase-\>compileTag('php', Array) #2 /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templateparser.php(3111): Smarty\_Internal\_Templateparser-\>yy\_r37() #3 /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templateparser.php(3211): Smarty\_Internal\_Templateparser-\>yy\_reduce(37) #4 /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_smartytemplatecompiler.php(105): Smarty\_Internal\_Templateparser-\>doParse(10, '??') # in /var/www/engine/Library/Smarty/sysplugins/smarty\_internal\_templatecompilerbase.php on line 627 Grüße

Ab Smarty3 ist der PHP Tag deprecated. Du mustt dein PHP in eine eigene Datei auslagern. Schau dir das einmal an: http://www.smarty.net/best_practices Vielleicht hilft es. Gruß Wolfgang

[quote=„Tina“]Danke für den Tipp. Ich habe eine php-Datei abgelegt unter engine/Library/Smarty/plugins/ Das funktioniert auch gut, ist ja aber nicht updatesicher. Gibt’s da noch eine andere Möglichkeit?[/quote] Die selbst erstellte Datei wird doch bei einem Update nicht gelöscht. Ich sehe da keine Probleme.

Hallo Leute, ich versuche auch gerade mein erstes Smarty Plugin einzubinden es soll in der /checkout/confirm.tpl eingebunden werden. das ist der Code, nur wie müsste der exakt in der php Datei aussehen? [code]<?php // your organization ID; provided by Lyoness //
$organization = “12345678”;
// your checksum code; provided by Lyoness //
$checksumCode = “09876543”;
// Value of the sale; sale specific value has to
// be assigned dynamically out of the shop database //
$orderValue = sAmount; // Currency of the sale. // For example "USD" for US , or “EUR” for Euro //
$currency = “EUR”;
// Event ID; provided by Lyoness //
$event = “456654”;
// Event type:
// in most cases $isSale should be left as “true” unless
// you arranged a lead commission with Lyoness
// true = Sale
// false = Lead //
$isSale = true;
// Encrypted connection on this page: // true = Yes (https)
// false = No (http)
//
$isSecure = true;
// Here you must specify a unique identifier for the transaction.
// you should assign your internal shop order number dynamically // out of your shop database
//
$orderNumber = $sOrderNumber;
// If you do not use the built-in session functionality in PHP, modify
// the following expressions to work with your session handling routines. //
tduid = ""; if (!empty(_SESSION[“TRADEDOUBLER”]))
tduid = _SESSION[“TRADEDOUBLER”];

        // OPTIONAL: You may transmit a list of items ordered in the reportInfo // parameter. See the 2.1.2 for details.
        //
        $reportInfo = ""; $reportInfo = urlencode($reportInfo);
        / ***** IMPORTANT:
        / ***** In most cases, you should not edit anything below this line.
        if (!empty($_COOKIE["TRADEDOUBLER"])) $tduid = $_COOKIE["TRADEDOUBLER"];
        if ($isSale) {
        *****/***** /
        } else {
        $domain = "tbs.tradedoubler.com"; $checkNumberName = "orderNumber";
        $domain = "tbl.tradedoubler.com"; $checkNumberName = "leadNumber"; $orderValue = "1";
        }
        $checksum = "v04" . md5($checksumCode . $orderNumber . $orderValue);
        if ($isSecure) $scheme = "https"; else $scheme = "http";
        $trackBackUrl = $scheme . "://" . $domain . "/report"
        . "?organization=" . $organization
        . "&checksum=" . "&tduid="
        . "&reportInfo="
        . $checksum . $tduid
        . $reportInfo;
        if ($isSale) {
        . "&event=" . $event
        . "&" . $checkNumberName . "=" . $orderNumber
        $trackBackUrl
        .= "&orderValue=" .$orderValue
        .= "&currency=" .$currency;
        }
        echo "<img src=\"" . $trackBackUrl . "\" alt=\"\" style=\"border: none\" />"; ?\>[/code] Bisher vermute ich dass es so sein muss: [code]<?php /*
  • Smarty plugin

  • File: function.lyoness.php
  • Type: function
  • Name: lyoness
  • Purpose: add Lyoness checksum Code

*/
function smarty_function_lyoness($params, $smarty)
{
// your organization ID; provided by Lyoness //
$organization = “12345678”;
// your checksum code; provided by Lyoness //
$checksumCode = “09876543”;
// Value of the sale; sale specific value has to
// be assigned dynamically out of the shop database //
$orderValue = sAmount; // Currency of the sale. // For example "USD" for US , or “EUR” for Euro //
$currency = “EUR”;
// Event ID; provided by Lyoness //
$event = “456654”;
// Event type:
// in most cases $isSale should be left as “true” unless
// you arranged a lead commission with Lyoness
// true = Sale
// false = Lead //
$isSale = true;
// Encrypted connection on this page: // true = Yes (https)
// false = No (http)
//
$isSecure = true;
// Here you must specify a unique identifier for the transaction.
// you should assign your internal shop order number dynamically // out of your shop database
//
$orderNumber = $sOrderNumber;
// If you do not use the built-in session functionality in PHP, modify
// the following expressions to work with your session handling routines. //
tduid = ""; if (!empty(_SESSION[“TRADEDOUBLER”]))
tduid = _SESSION[“TRADEDOUBLER”];

        // OPTIONAL: You may transmit a list of items ordered in the reportInfo // parameter. See the 2.1.2 for details.
        //
        $reportInfo = ""; $reportInfo = urlencode($reportInfo);
        / ***** IMPORTANT:
        / ***** In most cases, you should not edit anything below this line.
        if (!empty($_COOKIE["TRADEDOUBLER"])) $tduid = $_COOKIE["TRADEDOUBLER"];
        if ($isSale) {
        *****/***** /
        } else {
        $domain = "tbs.tradedoubler.com"; $checkNumberName = "orderNumber";
        $domain = "tbl.tradedoubler.com"; $checkNumberName = "leadNumber"; $orderValue = "1";
        }
        $checksum = "v04" . md5($checksumCode . $orderNumber . $orderValue);
        if ($isSecure) $scheme = "https"; else $scheme = "http";
        $trackBackUrl = $scheme . "://" . $domain . "/report"
        . "?organization=" . $organization
        . "&checksum=" . "&tduid="
        . "&reportInfo="
        . $checksum . $tduid
        . $reportInfo;
        if ($isSale) {
        . "&event=" . $event
        . "&" . $checkNumberName . "=" . $orderNumber
        $trackBackUrl
        .= "&orderValue=" .$orderValue
        .= "&currency=" .$currency;
        }
        echo "<img src=\"" . $trackBackUrl . "\" alt=\"\" style=\"border: none\" />"; } ?\> [/code] aber ich hab echt noch keine Ahnung wie ich es dann in die .tpl Datei einbinden würde. Bin für alle Tipps dankbar. Grüße aus Köln