MSM Site List Custom Field for EE2
Just created this EE2.0 field type as I wanted the control panel users to be able to select which site their channel entries get shown on, as opposed to hard coding this via the templates, or having the user switch between sites.
Using some simple filters in your templates, (eg query module) you can grab channel entries and filter by the custom field you have setup.
The fieldtype records the site short name in the database, but this can be converted to the site label, id or description via the display parameter.
Download ft.cki_sitelist.ee_addon
Requirements
- ExpressionEngine 2.0
Installation
- Copy
ft.cki_sitelist.phpto yoursystem/expressionengine/fieldtypes/folder. - Select CKI Site List as the field type when creating a new custom field type
How to use
The field type supports single tags only. Use the tag on its own to return the selected site short_name_
Simple Example
Lets say you have defined a custom field with a field label of Site list and field name site_list and through the publish form selected a site with an short_name of “default_site”. You can produce the site short name of the selected site by simply calling the field name tag on its own:
{exp:channel:entries channel="blog"}
<p>You selected site short name is {site_list}</p>
{/exp:channel:entries}
Returns:
<p>You selected site short name is {site_list}</p>
Parameter Example
Using the same site you have selected in the above example, we can retrieve different site attributes by using the display parameter:
{exp:channel:entries channel="blog"}
<p>You selected site ID is {site_list display="id"}</p>
{/exp:channel:entries}
Returns:
<p>You selected site ID is 1</p>
Parameters
Display
display="label"
Allows you to specify what site attribute to return. This parameter is optional, and if not used, the tag will return the site short name by default.
Accepts the following variables:
- id – Return the site id
- label – Returns the site label
- short_name – Returns the site short name
- description – Returns the site description
Changelog
1.0
- Initial Commit
Leave a Reply