This method was created for SEO edits on the Bitrix site (generated h1 values were entered in the file and displayed in the template). Today I returned to this solution for canonical edits, here is the code and description:
<?php include($_SERVER['DOCUMENT_ROOT']."/seo.php"); if(isset($seoh1) AND $seoh1!='') {echo $seoh1;} else {echo $heading_title;} ?>
First create a file seo.php with the following code:
<?php if ($_SERVER['REQUEST_URI'] == '/url1') { $seoh1 = 'test1'; } else if ($_SERVER['REQUEST_URI'] == '/url2') { $seoh1 'test2'; } ?>
Here is the description:
The case – I need to display 100500 values provided by the SEO for 100500 URLs. I don’t want to make an unlimited file with the same type of conditions, so I put all the values in a separate file, include it in the template and then check – “If the value for this variable is specified for this URL, then display it”, and if this file does not contain the requested URL, then I’m going to display the default value, where h1 – is $heading_title.