Mixed Content

This example combines the standard internal content usage from the basic example and the external content example.

Adding/Removing Items

{exp:channel:entries channel="news"}
	<h2>{title}</h2>
	{exp:shortlist:item entry_id="{entry_id}"}
	{if in_list}
		<a href="{add_url}">Add Item</a>
	{if:else}
		<a href="{remove_url}">Remove Item</a>
	{/if}
	{/exp:shortlist:item}
{/exp:channel:entries}

… snip …

<h2>External One</h2>
{exp:shortlist:item
	is_external="yes"
	unique_attr="attr:src"
	attr:title="External One"
	attr:src="http://somewhereelse.url/one"
	attr:blurb="This is an additional blurb for the item"
	attr:type="user_generated"}
{if in_list}
	<a href="{add_url}">Add Item</a>
{if:else}
	<a href="{remove_url}">Remove Item</a>
{/if}
{/exp:shortlist:item}

… repeat …

Will give you something like this :

<h2>Entry One</h2>
<a href="http://site.url?ACT=12&p=…">Add Item</a>

<h2>Entry Two</h2>
<a href="http://site.url?ACT=13&p=…">Remove Item</a>

<h2>Entry Three</h2>
<a href="http://site.url?ACT=13&p=…">Remove Item</a>

<h2>External One</h2>
<a href="http://site.url?ACT=12&p=…">Add Item</a>

<h2>External Two</h2>
<a href="http://site.url?ACT=13&p=…">Remove Item</a>

<h2>External Three</h2>
<a href="http://site.url?ACT=13&p=…">Remove Item</a>

Viewing Items

Viewing items using the :view tag is still very simple, even with mixed content. Use the {is_external} variable to switch up your handling.

{exp:shortlist:view}
	{if count==1}
	<h3>Your Shortlist ({total_results} Items)</h2>
	<ul>
	{/if}
	<li>
		{title} (<a href="{remove_url}">Remove</a>)
		{if is_external}
		Item Source : {attr:src}
		Blurb : {attr:blurb}
		{/if}
	</li>
	{if count==total_results}</ul>{/if}
	{if no_results}Your list is empty{/if}
{/exp:shortlist:view}

Will give you something like this :

<h3>Your Shortlist (2 Items)</h3>
<ul>
<li>
	Internal One (<a href="http://site.url?ACT=13&p=…">)Remove</a>
</li>
<li>
	External Three (<a href="http://site.url?ACT=13&p=…">)Remove</a>
	Item Source : http://somewhereelse.url/three
	Blurb : This is another blurb
</li>
</ul>