I have some sudo code here
$image_position = left
switch($image_position){
case 'left':
$block_con = "require(locate_template('templates/block-media-left.php'))";
break;
case 'right':
$block_con = 'require(locate_template("templates/block-media-right.php"))';
break;
case 'center':
$block_con = 'require(locate_template("templates/block-media-center.php"))';
break;
default:
$block_con = 'require(locate_template("templates/block-text.php"))';
}
<div>
<?php echo $block_con; ?>
</div>
Depending on the value of the $image_position I want to load a different block of php found in a templates folder.
The switch works but echo a string and does not add the require code.
I didn't think it would but don't know how to do this.