A couple questions:
First, when you pass in variables through an embed such as
{embed="test/page" title="Foo"}normally on test/page you can access the title by using {embed:title}. If you don’t say title=“Foo” in the embed call, and don’t give title any value at all, what is the value of {embed:title} on the test/page page? Is it empty, just a “” value, or does EE just render it out as the actual string {embed:title}? Right now, it seems like it returns its actual string of {embed:title}.
Second and related question. I’m trying to set up an embed so that when users don’t pass in values for some variables, defaults are automatically set. For example, if they don’t say var1=“me” in the embed call, I can give var1 a default value instead. I’ve been trying to do this first with EE if statements, and then with a PHP-EE hybrid solution I found at http://ellislab.com/forums/viewthread/54024/.
Passed in: {embed:sc_server}
<?php
if ( '{embed:sc_server}' == "{embed:sc_server}")
{ ?>
yes {assign_variable:mg_server="EXPRESSION"}
<?php } else { ?>
no {assign_variable:mg_server2="{embed:sc_server}"}
<?php } ?>
{mg_server}
{mg_server2}Basically, trying to get PHP to handle the flow control because EE couldn’t seem to line it up right. If {embed:sc_server} returns its own variable name, assume the user didn’t pass anything in through the embed and give it its default value. Otherwise, give the var what it passed through the embed.
Now here’s the odd part. At first I had both assign_variable statements set to use the {mg_server} variable since only 1 should’ve been executed. And I’d get output indicating that only 1 if statement had been found to be true (via seeing the ‘no’ or ‘yes’). Yet mg_server always equalled the string {embed:sc_server}. I changed it to the above and found that even though I always still see only ‘no’, mg_server always equals EXPRESSION and mg_server2 always equals {embed:sc_server}. It’s like both assignments are still getting run somehow. The exact output that appears in the page source is:
Passed in: {embed:sc_server}
yes
EXPRESSION
{embed:sc_server}Is this expected behavior or am I doing something wrong? Is there an easier way to do this?