by
KK » Thu Apr 01, 2021 3:03 pm
Taking a second look at your code made me realise that there is a different issue at work as well.
- Code: Select all
<cms:php> $title = '<cms:show seo_title />'; </cms:php>
<?php
require('includes/head.php');
<?
In the code above, there are two blocks executing PHP code -
one is the native (<?php .. ?>) and the other is a Couch tag (<cms:php>..</cms:php>).
Now, the way things work in Couch, the native PHP gets the first shot. Only when it has fully executed, that Couch even gets to execute its first instruction.
So, coming to the code referenced above, although the Couch block of PHP comes before the native block, in reality the native part executed first. Which means that the code in your head.php executes before <cms:php> could set the variable.
And so, the following outputs a blank -
- Code: Select all
<title><?php echo $title; ?></title>
Alright, so what is the solution?
Though it can be done, it'll get unwieldy pretty soon if you try make native PHP blocks and their Couch counterparts work cooperatively.
The best way would be to forgo using
require('includes/head.php'); and, instead, use a normal Couch snippet (with <cms:embed>. It shouldn't be too difficult to port the PHP code within head.php to do things using Couch tags.
Hope this helps.