View previous topic :: View next topic |
Author |
Message |
Shimmy Smarty Rookie
Joined: 28 Aug 2006 Posts: 5
|
Posted: Mon Aug 28, 2006 10:40 am Post subject: Firefox Smarty Extension |
|
|
Hello,
I've created a Firefox extension that creates a frame around each smarty-template that are included. The frame shows the filename for the template. The templates can then be opened with your favorite editor with a single click.
In order for this to work, one need to make a little change in the Smarty.class.php file:
In the function _smarty_include($params):
Change:
Code: | if ($this->_is_compiled($params['smarty_include_tpl_file'],$_smarty_compile_path)
|| $this->_compile_resource($params['smarty_include_tpl_file'],$_smarty_compile_path))
{
include($_smarty_compile_path);
} |
To:
Code: | if ($this->_is_compiled($params['smarty_include_tpl_file'],$_smarty_compile_path)
|| $this->_compile_resource($params['smarty_include_tpl_file'],$_smarty_compile_path))
{
print "<!--Smarty:".$params['smarty_include_tpl_file']."-->";
include($_smarty_compile_path);
print "<!--Smarty end:".$params['smarty_include_tpl_file']."-->";
}
|
This change actually adds a html-comment before and after each template that are included. Anyone know a better way to do this?
So, if you wan't to try the extension:
1. make the changes to your Smarty.class.php
2. Download and install the SmartyExtension.xpi (http://www.badongo.net/file/1304000)
3. Restart firefox
4. You should now have a little smarty icon in your status-bar, left-click it and a menu pops up, visit your site, and choose "Show Smarty Templates"
Any ideas, feedbacks or bugs, give them to me |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Aug 28, 2006 10:55 am Post subject: Re: Firefox Smarty Extension |
|
|
Shimmy wrote: | This change actually adds a html-comment before and after each template that are included. Anyone know a better way to do this?
|
use a prefilter or a postfilter. |
|
Back to top |
|
Shimmy Smarty Rookie
Joined: 28 Aug 2006 Posts: 5
|
Posted: Mon Aug 28, 2006 11:03 am Post subject: Re: Firefox Smarty Extension |
|
|
messju wrote: | Shimmy wrote: | This change actually adds a html-comment before and after each template that are included. Anyone know a better way to do this?
|
use a prefilter or a postfilter. |
Ah, thanks for the tip, gonna try it. |
|
Back to top |
|
Shimmy Smarty Rookie
Joined: 28 Aug 2006 Posts: 5
|
Posted: Mon Aug 28, 2006 12:11 pm Post subject: Re: Firefox Smarty Extension |
|
|
messju wrote: | Shimmy wrote: | This change actually adds a html-comment before and after each template that are included. Anyone know a better way to do this?
|
use a prefilter or a postfilter. |
How do i get the name of the current template from within my post/prefilter?
Sorry for asking questions here..
EDIT: Forget that, i found it, $this->_current_file right? |
|
Back to top |
|
Shimmy Smarty Rookie
Joined: 28 Aug 2006 Posts: 5
|
Posted: Mon Aug 28, 2006 12:27 pm Post subject: |
|
|
Ok, if you wan't to use the postfilter method, do like this:
create the file postfilter.StartComment.php:
Code: | <?php
function smarty_postfilter_StartComment($source, &$smarty)
{
return "<!--Smarty:" . $smarty->_current_file . "-->" . $source . "<!--Smarty end:" . $smarty->_current_file . "-->";
}
?> |
And use register_postfilter method to include it. Or add it to the $autoload_filters array. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Aug 28, 2006 7:10 pm Post subject: |
|
|
Interesting and neat start!
If you incorporated debug info and allowed for multiple template paths, that would be cooler yet |
|
Back to top |
|
Shimmy Smarty Rookie
Joined: 28 Aug 2006 Posts: 5
|
Posted: Mon Aug 28, 2006 7:30 pm Post subject: |
|
|
boots wrote: | Interesting and neat start!
If you incorporated debug info and allowed for multiple template paths, that would be cooler yet |
Thanks,
Yes i have tought about that, multiple template paths depending on domain or url, and an option to view smarty debug.. hmm, i can force a debug window by adding debug=true to the url right? |
|
Back to top |
|
sprinklersystem Smarty Rookie
Joined: 23 Apr 2006 Posts: 8
|
Posted: Mon Sep 04, 2006 3:55 am Post subject: |
|
|
Tried this but getting smarty error:
Warning: Smarty error: unable to read resource: "" in smarty class line 1095 |
|
Back to top |
|
tobias_l Smarty Rookie
Joined: 11 Aug 2004 Posts: 24
|
Posted: Mon Nov 27, 2006 11:35 am Post subject: |
|
|
can you rewrite the extension to enable...
1. a mouse-over effect displaying the border and name of the template when moving the cursor over a specific template and
2. a possibility to click on the template region (that opens the template file in the editor) instead of circular choosing the template from the extensions menu in the status bar |
|
Back to top |
|
englishchrissy Smarty Rookie
Joined: 01 Nov 2006 Posts: 15
|
Posted: Fri Dec 01, 2006 9:19 pm Post subject: Are the istructions in this post still valid |
|
|
Hi, I would like to try the extension but are the instructions about changing smarty_class.php still required or have subsequent improvements negated them. Any good luck with this project. Cheers. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Dec 02, 2006 2:52 pm Post subject: Re: Are the istructions in this post still valid |
|
|
englishchrissy wrote: | Hi, I would like to try the extension but are the instructions about changing smarty_class.php still required or have subsequent improvements negated them. Any good luck with this project. Cheers. |
Read the full thread and use this prefilter instead of modifying the Smarty core. |
|
Back to top |
|
davidlt Smarty n00b
Joined: 19 Feb 2007 Posts: 2
|
Posted: Mon Feb 19, 2007 4:54 pm Post subject: |
|
|
Interesting... |
|
Back to top |
|
kauaicoder Smarty Rookie
Joined: 08 Dec 2005 Posts: 6 Location: Kauai, Hawaii
|
Posted: Tue Feb 20, 2007 2:13 am Post subject: |
|
|
Quote: | 2. Download and install the SmartyExtension.xpi (http://www.badongo.net/file/1304000) |
This file is no longer available. Any place else to get it? |
|
Back to top |
|
rgb Smarty Rookie
Joined: 04 Mar 2007 Posts: 9 Location: Hamburg / Germany
|
Posted: Sun Mar 04, 2007 1:07 pm Post subject: |
|
|
I want it, too. |
|
Back to top |
|
m1chu Smarty Rookie
Joined: 22 Jun 2008 Posts: 5
|
Posted: Sun Jun 22, 2008 12:56 pm Post subject: |
|
|
Nice one, thanks |
|
Back to top |
|
|