Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Firefox Smarty Extension
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
Shimmy
Smarty Rookie


Joined: 28 Aug 2006
Posts: 5

PostPosted: Mon Aug 28, 2006 10:40 am    Post subject: Firefox Smarty Extension Reply with quote

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 Smile
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Aug 28, 2006 10:55 am    Post subject: Re: Firefox Smarty Extension Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Shimmy
Smarty Rookie


Joined: 28 Aug 2006
Posts: 5

PostPosted: Mon Aug 28, 2006 11:03 am    Post subject: Re: Firefox Smarty Extension Reply with quote

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
View user's profile Send private message
Shimmy
Smarty Rookie


Joined: 28 Aug 2006
Posts: 5

PostPosted: Mon Aug 28, 2006 12:11 pm    Post subject: Re: Firefox Smarty Extension Reply with quote

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
View user's profile Send private message
Shimmy
Smarty Rookie


Joined: 28 Aug 2006
Posts: 5

PostPosted: Mon Aug 28, 2006 12:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Aug 28, 2006 7:10 pm    Post subject: Reply with quote

Interesting and neat start!

If you incorporated debug info and allowed for multiple template paths, that would be cooler yet Wink
Back to top
View user's profile Send private message
Shimmy
Smarty Rookie


Joined: 28 Aug 2006
Posts: 5

PostPosted: Mon Aug 28, 2006 7:30 pm    Post subject: Reply with quote

boots wrote:
Interesting and neat start!

If you incorporated debug info and allowed for multiple template paths, that would be cooler yet Wink


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
View user's profile Send private message
sprinklersystem
Smarty Rookie


Joined: 23 Apr 2006
Posts: 8

PostPosted: Mon Sep 04, 2006 3:55 am    Post subject: Reply with quote

Tried this but getting smarty error:

Warning: Smarty error: unable to read resource: "" in smarty class line 1095
Back to top
View user's profile Send private message
tobias_l
Smarty Rookie


Joined: 11 Aug 2004
Posts: 24

PostPosted: Mon Nov 27, 2006 11:35 am    Post subject: Reply with quote

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
View user's profile Send private message
englishchrissy
Smarty Rookie


Joined: 01 Nov 2006
Posts: 15

PostPosted: Fri Dec 01, 2006 9:19 pm    Post subject: Are the istructions in this post still valid Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Dec 02, 2006 2:52 pm    Post subject: Re: Are the istructions in this post still valid Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
davidlt
Smarty n00b


Joined: 19 Feb 2007
Posts: 2

PostPosted: Mon Feb 19, 2007 4:54 pm    Post subject: Reply with quote

Interesting...
Back to top
View user's profile Send private message
kauaicoder
Smarty Rookie


Joined: 08 Dec 2005
Posts: 6
Location: Kauai, Hawaii

PostPosted: Tue Feb 20, 2007 2:13 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
rgb
Smarty Rookie


Joined: 04 Mar 2007
Posts: 9
Location: Hamburg / Germany

PostPosted: Sun Mar 04, 2007 1:07 pm    Post subject: Reply with quote

I want it, too. Smile
Back to top
View user's profile Send private message
m1chu
Smarty Rookie


Joined: 22 Jun 2008
Posts: 5

PostPosted: Sun Jun 22, 2008 12:56 pm    Post subject: Reply with quote

Nice one, thanks Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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