Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ExpressionEngine 2 template utility tags
PHP
branch: master
Failed to load latest commit information.
system/expressionengine/third_party/moreutilities Added get and post methods
LICENSE.html Initial commit
README.textile

README.textile

moresoda

moreUtilities

An ExpressionEngine 2 add-on that provides various utility tags for use in templates.

Info

Developed by Moresoda Design Ltd, http://moresoda.co.uk

Requirements

  • ExpressionEngine 2.1.3 +

Browser Compatibility

  • Firefox 2+
  • Safari 2+
  • Chrome 3+
  • Opera 9+
  • Internet Explorer 7+

Installation

  1. Copy the system/expressionengine/third_party/moreutilities folder to your system/expressionengine/third_party/ folder.

Template Tags


member_custom_field

Example:

	{exp:moreutilities:member_custom_field member_id="5" field="screen_name"}

Allows you to display any member custom fields in your templates

Parameters

member_id
The ID of the member whose information you want to display

field
The custom member field name you would like to display.


member_id_to_name

Example:

	{exp:moreutilities:member_id_to_name member_id="5"}

Returns the screen name for a given member ID.


category_url_to_id

Example:

	<!-- Manually Specify -->
	{exp:moreutilities:category_url_to_id cat_url_title="how_to_articles" }
	
	<!-- Dynamically Specify -->
	{exp:moreutilities:category_url_to_id cat_url_title="{segment_3}" }

Returns the category ID for a given category URL title.

Parameters

cat_url_title
The URL title of a category to convert into an ID.


last_segment_to_cat_id

Example:

	{exp:moreutilities:last_segment_to_cat_id}

Convenience function, identical to category_url_to_id, except that it will automatically use the last segment of the current URL as the category URL title.


cat_url_to_name

Example:

	<!-- Manually Specify -->
	{exp:moreutilities:cat_url_to_name cat_url_title="how_to_articles"}
	
	<!-- Dynamically Specify -->
	{exp:moreutilities:cat_url_to_name cat_url_title="{segment_3}"}

Returns the category name for a given category URL title.

Parameters

cat_url_title
The URL title of a category to convert into a name.


next_entry_url_title

Example:

	{exp:moreutilities:next_entry_url_title cat_url_title="{segment_3}" entry_id="61"}

Return the URL title for the next entry in the same channel and the same category. Very useful if you are using categories on templates where the channel entries tag has dynamic="off", but you want to enable next/previous entry linking.

Parameters

cat_url_title
The category URL title for the category in which to search for the previous entry

entry_id
The current channel entry ID


prev_entry_url_title

Example:

	{exp:moreutilities:prev_entry_url_title cat_url_title="{segment_3}" entry_id="61"}

Return the URL title for the previous entry in the same channel and the same category. Very useful if you are using categories on templates where the channel entries tag has dynamic="off", but you want to enable next/previous entry linking.

Parameters

cat_url_title
The category URL title for the category in which to search for the previous entry

entry_id
The current channel entry ID


cache_buster

Example:

	<script src="/path/to/global/script.js{exp:moreutilities:cache_buster}" type="text/javascript"></script>
	<link href="/path/to/global/styles.css{exp:moreutilities:cache_buster}" type="text/css" rel="stylesheet"></script>
	
	<!-- Produces: -->
	<script src="/path/to/global/script.js?1265247835" type="text/javascript"></script>
	<link href="/path/to/global/styles.css?1265247835" type="text/css" rel="stylesheet"></script>

Allows you to take safely take advantage of browser caching for site assets such as CSS, JS, and image files, by being able to force visiting browsers to refresh their cache when they are updated.

The cache buster creates a timestamp you can use in your templates that is stored in the ExpressionEngine page cache. This means that once created, the timestamp remains the same as the user navigates around the site, and hence if the correct HTTP headers are being used for assets (see below) the browser will load the assets from it’s cache, dramatically decreasing the page load speed

If you update your CSS or JS files, simply empty the ExpressionEngine cache. This will delete the cache_buster timestamp, and force it to generate a new one. When browsers next visit the site with cached assets, the link to those assets will have changed due to the new timestamp that has been appended, and hence they will re download your newly updated assets!

The cache buster only works correctly on pages that have page caching enabled. If caching is disabled/refreshed then the browser will redownload the assets for each subsequent page where caching has not been enabled.

To take advantage of this for static assets you can place something similar to this in your .htaccess file (From HTML5 Boilerplate):

<!-- EXAMPLE -->
<IfModule mod_expires.c>
	ExpiresActive on

	ExpiresDefault                          "access plus 1 month"
	ExpiresByType text/css                  "access plus 2 months"
	ExpiresByType application/javascript    "access plus 2 months"
	ExpiresByType text/javascript           "access plus 2 months"
	
	<IfModule mod_headers.c>
		Header append Cache-Control "public"
	</IfModule>

</IfModule>

This technique can be applied to any kind of asset being used by your page.

On a side note, this works very well when being used with a versioned deployment mechanism such as Beanstalk coupled with a deployment hook such as our Beanstalk Web Hook addon. Each deployment will trigger a cache dump, thus forcing browsers to redownload assets the next time they visit.


get

Example:

	{exp:moreutilities:get key="address"}

Allows access to sanitised GET variables from within your templates.

Parameters

key
The name of the GET variable you want to display


post

Example:

	{exp:moreutilities:post key="address"}

Allows access to sanitised POST variables from within your templates.

Parameters

key
The name of the POST variable you want to display

Change log

1.1

  • Added get method
  • Added post method

1.0

  • Public release
Something went wrong with that request. Please try again.