|
Posted by Emil Tama on 01/03/05 00:24
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">
> <searchPattern
> paramNames="include_url"><![CDATA[/<%\s*include\s+file\s*=\s*["|']([^"^']*)[
> "|'][^}]*%>/im]]></searchPattern>
> </searchPatterns>
> <translator>
> <searchPatterns whereToSearch="smarty">
> <searchPattern
> paramNames="smarty_includeUrl"><![CDATA[/<%\s*include\s+file\s*=\s*["|']([^"
> ^']*)["|'][^}]*%>/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">
> <searchPattern
> paramNames="include_url"><![CDATA[/{\s*include\s+file\s*=\s*["|']([^"^']*)["
> |'][^}]*}/im]]></searchPattern>
> </searchPatterns>
> <translator>
> <searchPatterns whereToSearch="smarty">
> <searchPattern
> paramNames="smarty_includeUrl"><![CDATA[/{\s*include\s+file\s*=\s*["|']([^"^
> ']*)["|'][^}]*}/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 !
Navigation:
[Reply to this message]
|