|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Kopernikus Smarty n00b
Joined: 17 Mar 2013 Posts: 1
|
Posted: Sun Mar 17, 2013 1:47 pm Post subject: Smarty Bedingung mit Funktionen erstellen? |
|
|
Hallo zusammen
Ich bin noch blutiger Smarty Anfänger und möchte mich einer ersten Aufgabe in meinem xtc basierenden Webshop stellen. Im Template-System habe ich zwei Smarty Funktionen, welche ich gerne einer Bedingung unterstellen würde.
{products_attributes} fügt den Inhalt von Attributen in die Produkteseite ein. Darin eingeschlossen ist eine Lagerampel speziell für die Attribute. Das Problem ist nun, dass ich bei Produkten ohne Attribute keine Lagerampel angezeigt bekomme. Damit diese auch dort erscheint dient folgende Funktion: {lagerampel qty=$item.PRODUCTS_QUANTITY}
Nun möchte ich eine Bedingung erstellen, in welcher geprüft wird, ob Attribute vorhanden sind. Da {products_attributes} nur dann eingeblendet wird, wenn auch Attribute vorhanden sind, könnte ich doch prüfen, ob diese aktiv sind. Falls nicht, dann kommt die Funktion {lagerampel qty=$item.PRODUCTS_QUANTITY} zum zug.
Leider will mir diese Bedingung auch nach mehreren Stunden nicht gelingen. Vielleicht hat mir hier jemand einen Tipp, wie diese Bedingung in etwa aussehen müsste?
Herzlichen Dank im Voraus |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Mar 18, 2013 9:01 am Post subject: |
|
|
Um eine Bedingung abzufragen verwendet man IF-Abfragen. Also z. B. so
Code: | {if isset($item.PRODUCTS_QUANTITY)}Tu dinge, wenn PRODUCTS_QUANTITY existiert{else}Falls etwas passieren soll, wenn diese Bedingung nicht zutrifft{/if} |
Ich hoffe das meintest du |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|