我遇到了最奇怪的问题。
我正在创建一些自定义标题并实现用于共享的facebook开放图元标记
<meta name="description" content="<?php echo $metadescription; ?>" />
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:type" content="article"/>
<meta property="og:url" content="<?php echo $imageurl; ?>" />
<?php if ($adult == '1' && !$this->auth->loggedin()) : ?>
<meta property="og:image" content="<?php echo base_url(); ?>assets/images/fotoleaf-adult-image.jpg" />
<?php else : ?>
<meta property="og:image" content="<?php echo $image; ?>" />
<?php endif; ?>
<meta property="og:description" content="<?php echo $metadescription; ?>" />
<!-- Twitter Card data -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@fotoleaf">
<meta name="twitter:title" content="<?php echo $title; ?>">
<meta name="twitter:description" content="<?php echo $metadescription; ?>" >
<!-- Twitter Summary card images must be at least 200x200px -->
<?php if ($adult == '1' && !$this->auth->loggedin()) : ?>
<meta name="twitter:image" content="<?php echo base_url(); ?>assets/images/fotoleaf-adult-image.jpg">
<?php else : ?>
<meta name="twitter:image" content="<?php echo $image; ?>">
<?php endif; ?>
然而,除非我刷新页面,否则它似乎没有生效。所以我得到了未定义变量的所有PHP错误。
我正在加载它和所有其他视图一样。
$this->load->view('v1/header_photo_view', $data);
$this->load->view('v1/photo_view', $photodata);
$this->load->view('v1/footer');
// SOCIAL AND SEO
foreach ($photodata['photographer'] as $photog) {
if ($photog['firstName'] != NULL) {
$photogName = $photog['firstName'] . ' ' . $photog['lastName'];
} else {
$photogName = $photog['username'];
}
}
if ($photodata['photos']['title'] == NULL) {
$data['title'] = "Untitled. by ". $photogName;
} else {
$data['title'] = $photodata['photos']['title']. " by ". $photogName;
}
$data['metadescription'] = $data['title'] . " was shared on fotoleaf. The place to share only your best photos.";
$data['imageurl'] = site_url('photo') . "/" . $photodata['photos']['id'];
$data['image'] = $photodata['photos']['upload_path'] . $photodata['photos']['file_name'];
$data['adult'] = $photodata['photos']['adult'];
在加载之前是否有人强迫它刷新?
答案 0 :(得分:0)
我将$ data变量代码向下移动到加载视图之上,似乎已经修复了它。