Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Musterdaten bei Templateproblemen

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
jacz
Smarty Pro


Joined: 13 Nov 2010
Posts: 249

PostPosted: Sat Jan 14, 2012 2:14 pm    Post subject: Musterdaten bei Templateproblemen Reply with quote

In vielen Anwenderforen von Systemen die Smarty einsetzen gibt es immer wieder Fragen zu Templates und deren Ausführung.
Das Problem besteht darin das andere nicht exakt die gleiche Konfiguration, Module oder Plugins haben und natürlich auch ihre eigene Installation nicht verändern wollen nur um jemanden zu helfen.

Ich habe da schon lange ein kleines Plugin im Einsatz, mit dem man einfachst solche Smartyvars in einer Form exportieren kann, die andere durch simples Einfügen wieder bei sich zu einer Smartyvar machen können.
Damit sind aber andere in der Lage solche Smartyfragen beantworten zu können.

Man sollte so etwas auch bei Smarty selbst mitliefern:
Code:

<?php
#(c)2012 by Jan Czarnowski  (czarnowski@seitenreport.info)
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_function_var_export($params, &$smarty) {
    $name = isset($params['name']) ? $params['name'] : false;
    if (empty($name))
        return 'Kein Name vorgegeben';
    if (method_exists($smarty, 'getTemplateVars'))  // Smarty 3
        $var = $smarty->getTemplateVars($name);
    else
        $var = $smarty->get_template_vars($name);
    if (empty($var))
        return $name .' unbekannt';
    echo '{$' . $name . '=\'' . serialize($var) . '\'|unserialize}';
}

?>

Das Plugin arbeitet unter Smarty 2 und Smarty 3.
Einsatz in Inhaltsbereichen wo die benötigte Smartyvar zur Verfügung steht, sie wird verarbeitet ausgegeben.

Dann schaut man sich den Quelltext an, kopiert den Teil und kann ihn dann zur Verfügung stellen.

Einsatz z.B. {var_export name='menu'} , wobei menu der Name der Smartyvar ist, sie wird über den Namen auch ausgegeben.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP