View template source with Symfony
Par COil,
12/04/2007 à 11:17 :: #16
:: rss :: Tags :: plugin
| snippets
| symfony
[En] A little snippet to display the source code of the current main template displayed in a hidden div, the template (here it is a test of the sfGeshi plugin) (1)
[Edit 20/05/07] You can find a demo here (on the demo of the sfJoomlaBridge)
[Fr] Un petit snippet qui permet d'afficher le code source du template courant utilisé dans un div caché. Le template (ici je faisais un test du plugin sfGeshi)
[Edit 20/05/07] Vous pouvez trouver une demo ici (sur la demo de mon plugin sfJoomlaBridge)
<h1>sfGeshiPlugin</h1>
<div id="demo">
<?php $highlighter = new sfGeshi(file_get_contents(myTools::getTemplatePath()), 'php'); ?>
<?php echo $highlighter->parse_code(); ?>
</div>
<?php include_partial('global/view_source_link'); ?>
[En] The view source link template (_view_source_link.php)
[Fr] Ici le code du template permettant d'afficher le lien pour visualiser le code source
<div id="source-content">
<hr/>
<?php $highlighter = new sfGeshi(file_get_contents(myTools::getTemplatePath()), 'php'); ?>
<p>
<?php echo link_to_function(
'» Show source code of this template',
visual_effect('SlideDown', 'source')
); ?>
</p>
<div id="source" style="display:none">
<?php echo $highlighter->parse_code(); ?>
<p>
<?php echo link_to_function(
'» Close source code',
visual_effect('SlideUp', 'source')
); ?>
</p>
</div>
</div>
[En] And the function to get the physical path of the template :
[Fr] Et la fonction permettant de récupérer le chemin physique du template principal en cours :
<?php public static function getTemplatePath() { $context = sfContext::getInstance(); $module = $context->getModuleDirectory(); $template = $context->getCurrentViewInstance()->getTemplate(); return $module. DIRECTORY_SEPARATOR. 'templates'. DIRECTORY_SEPARATOR. $template; } ?>










Commentaires
Aucun commentaire / no comment
Ajouter un commentaire / add comment
Commentaires fermés / comments closed