Hi John, Thanks so much for your full and helpful answer, including the link to the variable variable documentation. Much appreciated. I think there may be an error on line 23 with the braces?
if ($has_content} {
Not sure if this should be:
if {$has_content} {
OR
if ($has_content) {
Many thanks
Paul