Monday , February 3 2025

Include the file and display the value if it is specified in this file

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.

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

How to remove h3 from AAPF – Advanced Ajax Product Filters (Rocket)

This article is about how to remove unused h3 tags, but not completely – just …

Leave a Reply

Your email address will not be published. Required fields are marked *