Smarty Framework

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Smarty Framework - Presentation Transcript

    1. Smarty Template Engine Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    2. Agenda
      • Template Engines
      • Vorteile einer Template Engine
      • Smarty Template Engine
      • Methoden der Klasse
      • Kontrollstrukturen / Operatoren
      • Livebeispiele
      • Kompilieren & Cachen
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    3. Template Engine?
      • Wozu?
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    4. Der „PHP-Weg“ <? include (‘header.php‘); ?> <? echo $result;?> Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    5. PHP Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    6. Trennung von Applikation und View Applikation und View Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
      • Redesigns unabhängig der Applikation
      • Änderungen im Code unabhängig von Views
      • „Kein“ KnowHow von PHP nötig für den Designer
      • Applikation bleibt sicher
      • Wiederverwendbarkeit von Views
      Trennung von Applikation und View Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    7. Template Engines phemplate RainTPL XTemplate VTemplate vlibTemplate Smarty Savant3 Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    8. Smarty - Template Engine „ Eine Template Engine ist eine Software, die eine Datei (das Template ) verarbeitet, und bestimmte Platzhalter darin mit jeweils aktuellen Inhalten füllt.“ Framework Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    9. Was leistet Smarty
      • Trennung von Applikation & View
      • Template-Funktionen / Modifikatoren
      • Caching
      • Debugging
      • offene Plugin-Architektur
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    10. Die Smarty Klasse Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    11. Methoden der Klasse Smarty
      • void assign (mixed $var)
      • void display ( string $template [, string $cache_id [, string $compile_id]] )
        • void register_object ( string $object_name, object $object [, array $allowed_methods_properties ...] )
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    12. Templates anzeigen Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    13. PHP Objekt zuweisen Klasse Person Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    14. PHP Objekt zuweisen .php .tpl Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    15. PHP-Objekte im Template $smarty -> register_object ( &quot;user&quot; , $myobj ,array( 'meth1' , 'meth2' , 'prop1' )); {user->meth1 p1=&quot;foo&quot; p2=$bar assign=&quot;output&quot;} ausgabe war: {$output} via $smarty->register_object Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    16. Kontrollstrukturen im Template
      • {if} {elseif} {else} {/if}
      • {foreach}
      • {section}
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    17. Smarty PHP == / eq != / neq > < >= <= ! is [not] even == != > < >= <= ! $a % $b == 2 Vergleichsoperatoren Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    18. Variablen im Template
        • {$auto}
        • {$auto[3]}
        • {$auto.farbe}
        • {$auto->farbe}
        • {$auto->verbrauch()}
        • {#konfigvar#}
      einfache Variable Array Auto an Stelle 4 Array Assoziativ Objekteigenschaft Objektmethode Konfigurationsvariable Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    19. Reservierte VAR {$smarty}
      • {$smarty.get.name}
      • {$smarty.post.name}
      • {$smarty.session.id}
      • {$smarty.now}
      $_GET[‘name‘]; $_POST[‘name‘]; $_SESSION[‘id‘]; date (U); smarty php Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    20. VAR-Modifikatoren
      • date_format
      • truncate (kürzen)
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    21. Smarty Live: „getting started“ Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    22. Templates kompilieren & cachen Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    23. Kompilierte Templates
      • Einmaliges Parsing des Templates
      • Umwandlung in PHP
      • => Schnellere Verarbeitung als ein Parser
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    24. Caching von Templates
      • Gerenderte Templates werden als „HTML“ temporär gespeichert
      • Cache kann für jede Datei individuell eingestellt werden.
      $smarty->caching = true; Aktivieren mit: Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    25. Caching von Templates <?php require('Smarty.class.php'); $smarty = new Smarty; $smarty->caching = true; $smarty->display('index.tpl'); ?> Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    26. Caching von Templates $smarty->caching = 1 $smarty->caching = 2 aus: $cache_lifetime aus: $cache_lifetime zur Laufzeit $smarty->cache_lifetime = -1; $smarty->cache_lifetime = 0; $smarty->cache_lifetime = 300; läuft nie ab kein Caching 5 Minuten in Sekunden Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    27. Caching von Templates $smarty->caching = 2; // Standardwert für '$cache_lifetime' auf 10 Minuten setzen $smarty->cache_lifetime = 600; $smarty->display('bus.tpl'); // '$cache_lifetime' für 'teilnehmer.tpl' auf 1 Stunde setzen $smarty->cache_lifetime = 3600; $smarty->display('teilnehmer.tpl'); Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    28. is_cached(string $template); if(!$smarty->is_cached('bus.tpl')) { $reisende = get_reisende(); $smarty->assign(‘reisende‘,$reisende); } $smarty->display('bus.tpl'); PHP muss nicht mehr ausgeführt werden wenn ein Cache vorhanden ist Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    29. Multiples Caching einer Seite <?php require('Smarty.class.php'); $smarty = new Smarty; $smarty->caching = true; $my_cache_id = $_GET['reise_id']; $smarty->display('bus.tpl',$my_cache_id); ?> Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    30. Multiples Caching einer Seite if(!$smarty->is_cached('bus.tpl',$my_cache_id)) { $reisende = get_reisende(); $smarty->assign($reisende); } $smarty->display('index.tpl',$my_cache_id); Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    31. Kompilierung & Caching
      • Livebeispiel
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    32. Vorteile des Smarty Frameworks
      • Trennung von Applikation und View
      • Wiederverwendbarkeit von Layouts
      • Designer haben keinen Zugriff auf den Programm-Code
      • Caching von Templates
      • Template-Debugging
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    33. Weitere Fragen? Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    34. Vielen Dank für Ihre Aufmerksamkeit Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel
    35. Quellen:
      • Smarty Manuel:
      • http://smarty.net/manual/de/
      • Wikipedia:
      • http://de.wikipedia.org/wiki/Template_Engine
      • PHP Manuel:
      • http://www.php.net/manual/de/
      Website-Entwicklung mit Datenbanken (WS 08/09) Präsentation von Ralf Ohlenbostel

    + capsnordcapsnord, 10 months ago

    custom

    913 views, 1 favs, 1 embeds more stats

    presentation about the usage of the smarty framewor more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 913
      • 906 on SlideShare
      • 7 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds
    • 7 views on http://www.dunkelfels.de

    more

    All embeds
    • 7 views on http://www.dunkelfels.de

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories