I have two fields :
- summary - textarea
- summary_de - textarea
I want to detect if $summary_de is empty
if its empty show $summary
if $summary is empty show nothing
I have tried the following tests :
// Test A
if ($page->summary_de) {
echo "Test A : True";
} else {
echo "Test A : False";
}
echo "<hr />";
// Test B
if (empty($page->summary_de)) {
echo "Test B : True";
} else {
echo "Test B : False";
}
echo "<hr />";
// Test C
if (isset($page->summary_de)) {
echo "Test C : True";
} else {
echo "Test C : False";
}
echo "<hr />";
// Test D
if (isset($page->summary_de) && $page->summary_de === '') {
echo "Test D : True";
} else {
echo "Test D : False";
}
echo "<hr />";
// Test E
if (is_null($page->summary_de)) {
echo "Test E : True";
} else {
echo "Test E : False";
}
The results on a published page when $summary_de is empty
Test A : True Test B : False Test C : True Test D : False Test E : False
adding some text into $summary_de and saving :
Test A : True Test B : False Test C : True Test D : False Test E : False
after removing the $summary_de text and saving again (so its empty) - same results.
Test A : True Test B : False Test C : True Test D : False Test E : False
So all the tests are the same. Any ideas where I am going wrong? Tried deleting cache, but still the same.
I'm using latest version of 2.1 from github.
Thanks,
Michael













