Its been a long time since substitutions received some love so to speak. That time has finally arrived. Primarily IF substitutions have finally been given the power to provide significantly more complex usage scenarios. Have you ever wanted to have an IF substitution inside of an IF substitution or define what should output in the event that IF substitution failed? This is all possible now using the below syntax.
[cb:if username="demo"]This is Demo being displayed.[cb:else]This is NOT Demo being displayed.[/cb:else][/cb:if]
In the above scenario if the username is demo they'll see "This is Demo being displayed.", but if they are not they will see "This is NOT Demo being displayed.". Now lets take it a step further with an ELSEIF. That's correct, you can ELSEIF too!
[cb:if username="demo"]This is Demo being displayed.[cb:elseif username="admin"]This is Admin being displayed.[/cb:elseif][cb:else]This is NOT Demo OR Admin being displayed.[/cb:else][/cb:if]
This gives you essentially the power of PHP IF statements at your finger tips using nothing but substitutions! All locations that support substitutions can instantly make use of this new functionality, but it doesn't stop there. You can also have IF substitutions inside of IF substitutions.
[cb:if username="demo"]This is Demo being displayed.[cb:if user_id="myid"] I am also viewing my self![cb:else] I am not viewing my self![/cb:else][/cb:if][/cb:if]
Yes, you are seeing that correctly. A nested IF statement with its own ELSE case as well. You can nest as many IF statements as you want as they'll all chain and parse out as needed. More importantly we've SIGNIFICANTLY improved the performance of IF substitutions. Previously if you have a string of about 300 characters inside of an IF substitution it would crash your site. This is no longer the case. The REGEXP has been greatly improved allowing strings of, potentially, unlimited length. Strings as large as 50,000 characters have been tested with lightning fast results.
Now onto the next goodie. Core substitutions have always been rather limited to primarily core fields and tabs. API wise we could only send some basic substitutions to be parsed like [MY_VARIABLE]. We've now added a trigger to our primary substitution parsing function. What this means is, potentially, plugins can extend the core substitution API with new substitution usages that would affect all substitution usages throughout CB. This means for example the awesome format functions in CB Auto Actions could soon come to all locations that support substitutions. The new CB Gallery substitutions could come to all locations that support substitutions instead of only Joomla content.prepare supported locations.
This is a very exciting time for substitutions. It paves the way for stronger and more efficient substitutions now and for the foreseeable future. I hope you are all as excited as I am as I look forward to integrating our various plugins into substitutions allowing for an even more flexible site!