Dynamic meta tags in php
- Get link
- X
- Other Apps
// red code for get current url
// green code for get dynamic meta tags
In Codeigniter pass the data in header page just like below :
$data = select record from table
$this->load->view('common/header,data);
<?php
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
// Append the host(domain name, ip) to the URL.
$url.= $_SERVER['HTTP_HOST'];
// Append the requested resource location to the URL
$url.= $_SERVER['REQUEST_URI'];
$where=[
'status' =>'A',
];
$data= $this->app_model->select_all('meta',$where);
?>
<meta name="google-site-verification" content="zCAmvLStTnJOn0gXqNfKfHeN1Hr0Xvk0C4xzvvwSEUg" />
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
// Append the host(domain name, ip) to the URL.
$url.= $_SERVER['HTTP_HOST'];
// Append the requested resource location to the URL
$url.= $_SERVER['REQUEST_URI'];
$package=strpos($url,'package');
$service=strpos($url,'service');
$about=strpos($url,'about');
foreach($data as $list){ if(@$list->meta_for==1){ if($package=='' && $service=='' && $about == ''){ ?>
<title>CuDel - Beauty Salon at Home | Beauty Services at Home</title>
<meta name="description" content="<?=@$list->meta_description?>"/>
<?php }} else if(@$list->meta_for==4){ if($package){ ?>
<title><?=@$meta->meta_title?></title>
<meta name="description" content="<?=@$meta->meta_description?>"/>
<?php }}
else if(@$list->meta_for==3){ if($service){ ?>
<title><?=@$category->meta_title?></title>
<meta name="description" content="<?=@$category->meta_description?>"/>
<?php }}
else if(@$list->meta_for==2){ if($about){ ?>
<title>Beauty Salon at Home | For Booking Contact @ 9311147877</title>
<meta name="description" content="<?=@$list->meta_description?>"/>
<?php }}
} ?>
<link rel="canonical" href="<?php echo @$url ?>" />
- Get link
- X
- Other Apps
Comments
Post a Comment