0
我碰到過最奇怪的問題。在顯示自定義標題之前需要刷新Codeigniter頁面?
我創建了一些自定義標題和落實Facebook開源圖形meta標籤的分享
<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'];
有沒有辦法強制它在刷新之前刷新?
我可以顯示$數據變量 – Ts8060