Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Relationship fieldtype for ExpressionEngine P&T Matrix fields

License

Notifications You must be signed in to change notification settings

ckimrie/ft.matrix_relations.ee_addon

Repository files navigation

moresoda

moreMatrixRelations

Provides a lightweight relationship fieldtype for use with Pixel & Tonic Matrix .

Info

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

Requirements

  • ExpressionEngine 2.1.3 +
  • P&T Matrix 2.2+

Browser Compatibility

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

Installation

  1. Copy the system/expressionengine/third_party/morematrixrelations folder to your system/expressionengine/third_party/ folder.
  2. Go to Add-ons→Fieldtypes in the ExpressionEngine control panel and install the fieldtype labelled moreMatrixRelations.
  3. You will now see moreMatrixRelations as a fieldtype option when creating & editing P&T Matrix fields

Example Usage

Simple Example

If you have setup a Matrix field called ‘people’ and within the Matrix settings you have created a moreMatrixRelations field called ‘name’, your templates may look like this. The fieldtype:

	{exp:channel:entries channel="channel_name"}
		{people}
			<ul>
				{name}
					<li>{title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

The output could be something like the following:

	<ul>
		<li>John Smith</li>
		<li>Richard Jones</li>
		<li>Sarah Richards</li>
	</ul>
	<ul>
		<li>James Parker</li>
		<li>Sarah Richards</li>
	</ul>

Parameter Example

You can control the sort order using the ‘orderby’, ‘sort’ parameters and filter by entry status by using the ‘status’ parameter:

	{exp:channel:entries channel="channel_name"}
		{people}
			<ul>
				{name orderby="entry_date" sort="desc" status="open"}
					<li>{title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

The status parameter can also accept custom channel status names.

Use the ‘prefix’ parameter to prefix all variable names, which helps prevent collisions with variables from the {exp:channel:entries} tag:

	{exp:channel:entries channel="channel_name"}
		<h1>{title}</h1>
		{people}
			<ul>
				{name prefix="name"}
					<li>{name:title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

Variables

The field type must always be used as a tag pair. The following top level channel entry variables are available inside the moreMatrixRelations tag pair:

  • entry_id
  • title
  • url_title
  • site_id
  • channel_id
  • author_id
  • status
  • page_uri

Channel custom fields are not available.

Parameters

orderby

Example:

	{exp:channel:entries channel="channel_name"}
		{people}
			<ul>
				{name orderby="entry_date"}
					<li>{title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

This parameter will allow you to customise the display order of the selected entries. The default sort order will be ascending. Valid field names are the same as the variables made available in the template tags:

  • entry_id
  • title
  • url_title
  • site_id
  • channel_id
  • author_id
  • status
  • page_uri

sort

Example:

	{exp:channel:entries channel="channel_name"}
		{people}
			<ul>
				{name orderby="entry_date" sort="asc"}
					<li>{title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

This parameter can only be used in conjunction with the ‘orderby’ parameter. Valid sort options are:

  • asc
  • desc
  • random

status

Example:

	{exp:channel:entries channel="channel_name"}
		{people}
			<ul>
				{name status="closed"}
					<li>{title}</li>
				{/name}
			</ul>
		{/people}
	{/exp:channel:entries}

Allows filtering of the selected entries by status. Default status fields are ‘open’ / ‘closed’ but custom status fields can also be used.

If the status parameter is not specified it will filter out ‘closed’ entries by default.

Change log

1.5.2

  • Fixed bug encountered when the publish form is submitted with required fields missing

1.5.1

  • Fixed bug where page_uri tag was not working

1.5

  • Ordering and sort parameters added to template tags
  • Status filter parameter added to template tags

1.4

  • Ability to select multiple entries from within the matrix field.
  • Configuration option to restrict selection to a single entry or allow the multi select.
  • Template tag updated to use tag pairs only.

1.3

  • Ability to select entries from multiple channels. Entries are listed organised by channel when using the fieldtype in a Matrix field.

1.2

  • Added page_uri to list of fields available in templates

1.1

  • Renamed the add-on moreMatrixRelations
  • Updated docs

1.0

  • Public release

About

Relationship fieldtype for ExpressionEngine P&T Matrix fields

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages