Re: Using Dreamweaver Design View Includes with Smarty
| From: | Emil Tama | Date: | Sun, 02 Jan 2005 22:24:03 +0000 |
| Subject: | Re: Using Dreamweaver Design View Includes with Smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12098@lists.php.net to get a copy of this message | ||
Marc Melvin wrote:
Hey everyone, I wasn't able to find much information on this topic when I started looking, but I was able to finally piece it together, and I just thought I would share it with everyone. The problem that I've had with Smarty for some time is mostly due to my designer's love for Dreamweaver. When we worked in straight PHP code, he didn't mind so much because Dreamweaver would automatically replace <?php include('file.php'); ?> with the contents of the file that was being included when in design mode. The problem arose with Smarty when we realized that <%include file="file.php"%> (we are using ASP style delimiters) would not return the same results, and there really weren't any solutions that we could find to correct the problem. (although, it seems that associating TPL files with JSP files and using the delimiters <%@ and %> would fix the problem, but that's just too easy of a hack for me) Well, after playing with some of Dreamweaver's configuration files and taking some hints from a few newsgroups, I finally figured out a quick and easy way to do it. First of all, you have to have the .TPL extension associated with PHP files in Dreamweaver. There are some other tutorials out there that will explain how to do this properly, but it's out of the scope of this email. Once you have Dreamweaver configured to read TPL files as PHP code, then you can create one file in Dreamweaver's configuration to make this work. Create an empty file called include_smarty.edml in the Configuration\ServerBehaviors\PHP_MySQL directory of your Dreamweaver MX install folder. (the default full path will be C:\Program Files\Macromedia\Dreamweaver MX 2004\Configuration\ServerBehaviors\PHP_MySQL\include_smarty.edml) Place the following code in this file: <participant> <searchPatterns whereToSearch="smarty"><searchPatternparamNames="include_url"><[ "|'][^}]*%>/im]]></searchPattern> </searchPatterns> <translator><searchPatterns whereToSearch="smarty"> <searchPatternparamNames="smarty_includeUrl"><["|'][^}]*%>/im]]></searchPattern></searchPatterns></translator> </participant> The only thing you will need to change is the <% and %> inside the CDATAs to be whatever delimiters you use. So Smarty's default delimiters { and } would use this instead: <participant> <searchPatterns whereToSearch="smarty"><searchPatternparamNames="include_url"><[" |'][^}]*}/im]]></searchPattern> </searchPatterns> <translator><searchPatterns whereToSearch="smarty"> <searchPatternparamNames="smarty_includeUrl"><["|'][^}]*}/im]]></searchPattern></searchPatterns></translator> </participant> Once you create this file, restart Dreamweaver, and the next time you open a TPL file with includes, it should pull the contents into design view just like PHP does. Hopefully this helps someone because I know I've been searching for months for this very simple solution, and finally it came to me (my designer's aren't complaining about stylesheets not being pulled in anymore from header files, etc, and that's all that matters to me). Smarty rocks! :) Enjoy, Marc Very nice, thanks !