Conditional extra content in bespoke tab.

jQuery based tabbed Product and Fragment Descriptions.
Post Reply
norman
Site Admin
Posts: 1239
Joined: Sat Feb 07, 2004 9:55 pm

Conditional extra content in bespoke tab.

Post by norman » Tue Apr 22, 2014 3:14 pm

Scenario: You want to have a group of layouts containing descriptive text for different Producers to show up on a PRODUCER tab. These will be chosen via a Selector called Producer that can optionally be No Layout.

In the Library / Layouts / Products, create a set of layouts containing text for each Producer and add them to a Selector called "Producer". In the Selector, check the Allow <No Layout> as an Option checkbox.

Edit layout TabbedProductDescription and look for the line:

Code: Select all

TBPRDSC;
Immediately after it, on a new line, add:

Code: Select all

$producer = <<<TBPROD
<actinic:variable name="Producer" />
TBPROD;
if ( strlen(trim($producer)) )
	{
	if ( preg_match('/(.*?)&#123;&#125;(.*)/s', $desc, $bits) )	// optional {} signifies end of tabbed text
		{
		$desc = $bits[1] . '&#123;PRODUCER&#125;' . $producer . '&#123;&#125;' . $bits[2];
		}
	else
		{
		$desc = $desc . '&#123;PRODUCER&#125;' . $producer;
		}
	}
That's it - your products will now have a Producer entry where you can select the type of Producer to show. PRODUCER tab will only show (as last or only tab) if a layout containing text is chosen.
Norman

Post Reply