PHP Live Templates

Are there PHP live templates (coming soon)?  I know when they do come any I write will pale in comparison, so just seeing if I can skip that step.


Comment actions Permalink

This task is not yet scheduled.  Please, create an issue in our tracker to track this task progress. Also, we'd appreciate attachment of your own templates so we can gather best ideas from all users :)

Comment actions Permalink

im wondering how to get the functions to work in the php live templates?

here is a list of functions but putting something like the date() into a live template does not replace it like i was expecting.


* $date()$
* Custom Modules
* @package apCustomCss
* @copyright 2009 by
* @author Michael Ussher
// make sure we are not being called directly
defined('IN_SYSTEM') or exit();

I was expecting the date() to be replaced by todays date.

also hoping that variables can be determined.  like if this live template is called from the apCustomCss directory that this variable will be able to be auto-inserted instead of typed by the user.

Comment actions Permalink


Based on your code sample I assume you are asking about file templates. To have date printed there try $DATE$

The documentation you reference is for live templates, not file templates. Live templates are code snippets that you can auto-expand to code faster.

Hope it helps,

Comment actions Permalink

Hi Eugene,

Yes that does help.  I can see for the starting a file that the file templates are probably better than the live templates.

I have one of those set up for my module includes pages now.  But i still cant see how to get the functions to work in the live templates.

same as this page:

there are 2 sections: CONTROLS and FUNCTIONS
it was one of those in the 'Functions' section that i was trying to use with the live templates.  What i was doing was this.

1. with a current file open in the directory i wanted to create a new file from the editor hit shift+F5 to clone the current file with a different name.
2. ctrl+a to select everything, then del.
3. have a live template set up for apmod (type apmod+TAB)  and the template completes.

if i had date() in the live template it comes out as date() rather than being replaced.   I also tried $date() and $date()$  but neither worked.  i tried the capitalize('some text') expecting to see SOME TEXT but it came out capitalize('some text').

Its not so much of an issue now that i can see the file templates will do the setup for me.  But i dont understand from following the help page how the functions listed there are supposed to work.


Comment actions Permalink


Please try this:

  1. Define a variable, e.g. $DATE$
  2. Click 'Edit Variables'
  3. Use date() as expression for the variable, of whatever other function you need.

See screenshot below.


Comment actions Permalink

Thanks Eugene,

That works.  I hadn't even noticed the 'edit variables' button on the 'add live templates page'  the button spanned the width of the box and i thought it was a heading for the options below that. (I know it was refered to in the documentation but it didnt filter through into my head.)

These are really interesting.

I might be mis-understanding what the "Default value" is for but the description from the help says "In this text box, specify the default string to be entered in the  corresponding input field of the expanded template, if the                         expression does not give any result after  calculation."

This is what i put for the default value

then when i used the live template in the php editor this is what i was expecting to see:

but what i actually got in the editor was:

Which makes me wonder what the "Default value" is for.


Please sign in to leave a comment.