/
Seiten "Pages" erstellen
Seiten "Pages" erstellen
Das Erstellen von neuen Seiten im FE des Shops ist ähnlich einfach wie das Erstellen von Boxen.
Zunächst muss im Hook page_registry.php:bottom die Seite definiert und die dazugehörige php-Datei inkludiert werden:
/plugins/xt_testplugin/hooks/page_registry_php_bottom.php
<?php defined('_VALID_CALL') or die('Direct Access is not allowed.'); define('PAGE_TEST', _SRV_WEB_PLUGINS.'xt_testplugin/pages/testpage.php'); require _SRV_WEBROOT.'plugins/xt_testplugin/classes/class.xt_testplugin.php';
Die .php-Datei wird im Ordner /pages/ innerhalb des Plugins abgelegt.
In dieser Datei werden Daten beliebiger Form abgefragt:
/plugins/xt_testplugin/pages/testpage.php
<?php defined('_VALID_CALL') or die('Direct Access is not allowed.'); $value = 'my random value...'; /* load an array of products (from xt_startpageproducts)*/ require_once _SRV_WEBROOT._SRV_WEB_PLUGINS.'/xt_startpage_products/classes/class.startpage_products.php'; $startpage_products_page = new startpage_products($current_category_id); $my_array = $startpage_products_page->getStartPageProductListing($startpage_products_page_data_array); // Die Zuvor angefragten Daten werden in $tpl_data geschrieben: $tpl_data = array( 'my_value' => $value, 'my_products_array' => $my_array ); // In $tpl wird eine Template-Datei zugewiesen, diese wird zunächst in /templates/AKTIVES_TEMPLATE/plugins/PLUGINNAME/templates/ , // dann in /plugins/xt_testplugin/templates/ gesucht. Der Pfad im Template gibt entwicklern die Möglichkeit das Template // zu modifizieren ohne Dateien im Pluginordner zu ändern. $tpl = 'mypage.html'; // Template() laden und Daten übergeben $template = new Template(); $template->getTemplatePath($tpl, 'xt_testplugin', '', 'plugin'); $page_data = $template->getTemplate('xt_testplugin_smarty', $tpl, $tpl_data);
Die dazugehörige Template-Datei muss diese Daten natürlich entsprechend ausgeben. Strings können ganz normal ausgegeben werden, Arrays werden durch foreach-Schleifen verarbeitet:
/plugins/xt_testplugin/templates/mypage.html
<!-- {debug} --> <h1>{$my_value}</h1> <!-- {* In $my_products_array befinden sich die Produktdaten, siehe "from=$my_products_array": *} --> {foreach name=aussen item=module_data from=$my_products_array} <div class="column {$smarty.const._STORE_TPL_LISTING_COLUMNS}"> <div class="box product box-hover"> {if $module_data.products_image == 'product:noimage.gif'} <p class="product-image"><a href="{$module_data.products_link}"><img src="{$tpl_url_path}img/no_image.png" alt="{$module_data.products_name|escape:"html"}" /></a></p> {if $module_data.base_price}<p class="vpe">{$module_data.base_price.price} {txt key=TEXT_SHIPPING_BASE_PER} {$module_data.base_price.vpe.name}</p>{/if} {else} <p class="product-image"><a href="{$module_data.products_link}">{img img=$module_data.products_image type=m_thumb class="productImageBorder" alt=$module_data.products_name|escape:"html"}</a></p> {/if} <p class="product-name"><a href="{$module_data.products_link}">{$module_data.products_name}</a></p> {if $module_data.review_stars_rating} <div class="product-reviews"> <div class="reviews_rating_light"> <div class="reviews_rating_dark" style="width:{$module_data.review_stars_rating}%"></div> </div> </div> {/if} {if $smarty.const._CUST_STATUS_SHOW_PRICE eq '1' and $module_data.products_price.formated neq ''} <p class="product-price">{$module_data.products_price.formated}</p> {if $module_data.products_shipping_link} <p class="product-tax-shipping">{$module_data.products_tax_info.tax_desc} <a href="{$module_data.products_shipping_link}" target="_blank" rel="nofollow">{txt key=TEXT_EXCL_SHIPPING}</a></p> {else} <p class="product-tax-shipping">{$module_data.products_tax_info.tax_desc} {txt key=TEXT_EXCL_SHIPPING}</p> {/if} {/if} {if $module_data.date_available!=''} <p class="box info">{txt key=TEXT_PRODUCT_AVAILABLE} {$module_data.date_available|date_format:"%A, %B %e, %Y"}</p> {/if} </div><!-- .box .product --> </div><!-- .column .four --> {/foreach}
Sollten Sie kein Template benötigen, können Sie ebenfalls die Templateausgabe unterdrücken, auf diese Art lassen sich z.B. Ajax-Applikationen, dynamische Javascripte oder css-Dateien realisieren.
, multiple selections available,
Related content
Frontend Hookpunkte
Frontend Hookpunkte
Read with this
Boxen erstellen
Boxen erstellen
Read with this
Hookpunkte
Read with this
Do's and don'ts bei der Veröffentlichung
Do's and don'ts bei der Veröffentlichung
Read with this
Versandkosten manipulieren
Versandkosten manipulieren
Read with this
Möglichkeiten der Error Loggings
Möglichkeiten der Error Loggings
Read with this