31

TLDR; In general, my preference would normally be to use a snippet, unless I need the variable content to be user editable (eg site email), and to only use an embed when parse order issues or similar necessitate it. Here's why... Snippets: Snippets are frequently my first choice for implementing reusable code fragments in EE. They are parsed at a very ...


20

You can (and should) save templates as files and then use the editor of your choice (as well as version your templates with Git/SVN/whatever). If for some reason that isn't an option for you there's Editee which is an extension that extends the CP template editor to make it more usable. EDIT: There's also ThEEditor and its Code Mirror based derivative ...


19

My URL schematic points out the difference it makes to the regular flow - might be helpful: http://www.jamessmith.co.uk/articles/expressionengine_url_schematic As you can see from the diagram, it prevents EE from determining a template via methods #2 and #4 method #2 as numbered there (and as alluded to in the other answers). For me the benefit of more ...


18

Well, my first question would be, why don't you have that <html> tag in your common/.head embed? Why is it separate? If you wish to have a template master page, take a look at the following links: http://johndwells.com/blog/homegrown-plugin-to-create-template-partials-for-expressionengine http://eeinsider.com/articles/template-partials-using-stash/ ...


18

There are several strategies for best utilizing 404s on a Structure site: Hide Structure Templates to Prevent Duplicate URLs First, make sure that any Structure-assigned templates are either hidden, or inside a hidden template group (prepend the group or template name with "_" or "." - so "_blog" or ".blog"). This ensures that there is no duplicate EE URL ...


16

As coded, your active states will not work. {if segment_1 == "home"} class="active"{/if} will work only if the browser page is reloaded and segment_1 becomes "home" in the address bar. Your hrefs aren't reloading the page, instead you are navigating with a scroll to "#home". If you want active states, you'll need to use jQuery to set the active class on ...


15

There isn't a native way to do JSON output in EE for channel data (AFAIK). Have you seen Rob Sanchez's JSON plugin? You just pass params as you would with {exp:channel:entries}. You can specify which fields to output, optionally set it to only output if an xhr is detected, and it will output member data too. You can then wrap the rest of your template in ...


15

Yeah, the smart cache-busting is a useful feature of keeping your CSS in EE. But add-ons will let you do the same and keep your CSS outside of EE. To get similar behavior for your JS files you need an an add-on. I recommend Minimee. Not only does it combine and minify CSS and JS, creating a cached file with a unique name, it also automatically creates a ...


14

I'm not familiar with Widgets, so this may or may not be helpful. If you are writing a plugin, generally you don't need to parse your own template code. Simply call: $variables = array(array('name' => 'adrian')); $this->EE->TMPL->parse_variables($template, $variables); Which will parse any variables, loops, or conditionals inside your template....


13

Preparse vars are best used for simple bits of data, not large chunks of code. This is because the Preparse vars are passed along to the variable content by means of a parameter, and large amounts of data (with line breaks, etc...) inside a parameter is never a good idea. Looking at your example, there aren't any embed variables being passed through the ...


12

Sounds like the field's settings have gotten mixed up at some point. I'd try switching the field to "XHTML" formatting, and select the option to "Update all existing channel entries with your new formatting choice?". Once that's done, then switch back to "None" formatting and update all existing again. Hopefully that will resolve for you.


10

I have recently used EE templates to make JSON output from channels that contain a range of custom fields, including P&T’s Playa, Matrix and Wygwam fieldtypes. Those that are not familiar with JSON might find this useful. While it is a bit fiddly, all that is really required is a resource who is familiar with the JSON syntax/format to help you craft the ...


10

To rewrap your question in a "pros/cons" list: Pros Editing through your favorite editor -> faster Enables you to version your files with a VCS You can DIFF files Easier to maintain code markup/layout Cons Slightly slower because EE needs to check the files for a new version (i guess it only uses the file versions in the latest EE releases). Could be a ...


9

With Strict URLs off, if your first segment doesn't correspond to an existing template group, EE will then look for a template with the same name in your default template group, and render that template if found. Enabling Strict URLs prevents the behaviour - if {segment_1} is not a template group (and your URL is not a Pages URL), you'll get a 404.


9

There is no native way to add additional fields to the EE Comment module, no. Freeform could work. You would have to have a hidden field that stored the entry_id of the entry being commented on, so that you could then use search:comment_entry_id="{entry_id}" when listing the comments with the Freeform Entries tag. (Note that you'd likely have to either ...


8

How about John Wells' Minimee? http://johndwells.github.com/Minimee/ It minifies the rendered HTML (EE 2.4+), and as far as I know, that's what you're looking for? I've only used it for CSS/JS and it works fabulously for that.


8

All three of these are used for enabling you to not repeat yourself when building sites, but they vary in functionality quite a lot. Global Variables Global Variables are used generally for storing pieces of content that might not be be part of an entry, for instance a contact form email address, a store address, etc. You can not use EE tags within a global ...


8

This is array_keys($row): Array ( [0] => template_id [1] => site_id [2] => group_id [3] => template_name [4] => save_template_file [5] => template_type [6] => template_data [7] => template_notes [8] => edit_date [9] => last_author_id [10] => cache [11] => refresh [12] =&...


8

A quick addendum to the other answers (which are both fine for reading back values): it is possible (and often a good idea) to change a text input field's allowed content from the default "all" to "integer", "number", or "decimal". You can do this on the edit field screen: This is important to do if you then want to filter/sort values numerically rather ...


8

You can use Ce_string for this, which is the ultimate swiss army knife. {exp:ce_str:ing htmlspecialchars=":CONST:ENT_QUOTES"}<a href='test'>Test</a>{/exp:ce_str:ing}


7

not natively but something like http://devot-ee.com/add-ons/hacksaw could easily do what you need. There's also http://devot-ee.com/add-ons/supergeekery-tag-stripper as well as some commercial add-ons that also give this kind of functionality.


7

I keep my site in online mode, but have the templates restricted to logged in members. When a non-logged in member visits the site they are redirected to a "splash" template with a login form. Once logged in they can see and do everything. You can set this up in template preferences - It should be just ejnough to redirect the homepage as no-one else should ...


7

ExpressionEngine does not appear to provide a way to deal with this scenario out-of-the-box. One solution would be to create a custom plugin like the following. I have intentionally named this "Utility Functions" because I plan to add additional functionality as needed. But hopefully this will save some time for future readers. <?php $plugin_info =...


7

The {exp:channel:categories} sadly does not have a limit parameter. GW Code Categories does have a limit parameter though (along with many other useful features when working with categories).


7

Sorry for the super simple answer, but I would just abstract your logic so you could execute the same function with the cron job as you would with the template tag. By creating an EE module you could create an ACT id to execute the cron job script, and use the plugin portion for the template. A common library would be the two that links it all together. ...


7

As someone who has been using EE for years, and going about templating in exactly the manner you are trying to for those many years, and who is just now learning a much easier way, I would like to suggest you look into using Stash. The difference is that in the EE templating method you are pursuing, and that I and many others used for years is that your ...


7

I know we talked about this on Twitter yesterday, but looking at the EE docs again it says: "Up to four different instances of the view counter can be used (each on a different page), enabling you to track different aspects of an entry independently" Which isn't immediately clear (at least in a pre-coffee state). So I did a quick test on my local ...


7

That would be the save templates as files feature. Once you've configured a template path you can save individual templates as files or you can sync all of your templates to file via the Templates > Synchronize Templates page. Once you've done that any changes you make to the template files will take effect immediately, without you needing to manually sync ...


7

You can't have a template group without an index template, but you don't have to use it. You could either set the preferences for the template in the CP to have it inaccessible to guests or simply place {if segment_2==""}{redirect="whatever"}{/if} in it to prevent access to the template directly.


Only top voted, non community-wiki answers of a minimum length are eligible