# Php in .tpl datein

**URL:** https://forum.shopware.com/t/php-in-tpl-datein/2955
**Category:** Shopware 3.5
**Tags:** templates--design
**Created:** [30. Mai 2011 um 23:55 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955 "2011-05-30T23:55:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cu-viper](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/cu-viper/32/18057_2.png) [@cu-viper](https://forum.shopware.com/u/cu-viper)
#### Post date: [30. Mai 2011 um 23:55 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/1 "2011-05-30T23:55:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![avenger](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@avenger](https://forum.shopware.com/u/avenger)
#### Post date: [31. Mai 2011 um 06:00 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/2 "2011-05-31T06:00:08Z")

</div>

[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 🙂 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.

---

<div class="post-metadata">

### Author: ![cu-viper](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/cu-viper/32/18057_2.png) [@cu-viper](https://forum.shopware.com/u/cu-viper)
#### Post date: [31. Mai 2011 um 10:17 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/3 "2011-05-31T10:17:57Z")

</div>

Ich mag den Shop immer mehr 🙂 Danke 🙂

---

<div class="post-metadata">

### Author: ![Neuland\_Communicatio](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@Neuland\_Communicatio](https://forum.shopware.com/u/Neuland_Communicatio)
#### Post date: [17. September 2012 um 13:53 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/4 "2012-09-17T13:53:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wpa](https://avatars.discourse-cdn.com/v4/letter/w/ac8455/32.png) [@wpa](https://forum.shopware.com/u/wpa)
#### Post date: [18. September 2012 um 16:24 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/5 "2012-09-18T16:24:41Z")

</div>

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](http://www.smarty.net/best%5C_practices) Vielleicht hilft es. Gruß Wolfgang

---

<div class="post-metadata">

### Author: ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)
#### Post date: [27. September 2013 um 00:06 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/6 "2013-09-27T00:06:41Z")

</div>

[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.

---

<div class="post-metadata">

### Author: ![great2gether](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/great2gether/32/12887_2.png) [@great2gether](https://forum.shopware.com/u/great2gether)
#### Post date: [24. Januar 2015 um 00:50 UTC](https://forum.shopware.com/t/php-in-tpl-datein/2955/7 "2015-01-24T00:50:58Z")

</div>

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
```
