在cakephp子域名网站中添加Facebook og标签 [英] Add Facebook og tags in cakephp subdomain sites

查看:78
本文介绍了在cakephp子域名网站中添加Facebook og标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cakephp的各个子域。例如,主域名是:www.example.com各个子域名可能是:abc.example.com,def.example.com



在每个子域名中域名,有课程页面。我想分享每个子域的每个课程页面。



我无法在layouts-> default.ctp文件中直接添加facebook og meta标签,因为每个课程页面都有自己的形象。



我做了如下:



在视图文件中:





I am working with various sub-domain of cakephp. For example, main domain is : www.example.com Various sub-domains may be: abc.example.com, def.example.com

In each sub-domain, there is courses page. I want to share each course page for each sub-domain.

I can't directly add facebook og meta tags in of layouts->default.ctp file because each course page has its own image.

I have done as following:

In view file:


<?php echo $this->Html->meta('description', $course['Course']['summary']);

    echo $this->Html->meta(array('property' => 'og:title', 'type' => 'meta', 'content' => $course['Course']['fullname'], 'rel' => null));
    echo $this->Html->meta(array('property' => 'og:url', 'type' => 'meta', 'content' => Configure::read('http').Configure::read('storeName').'.'.Configure::read('site_lms').'Course/view/'.$course['Course']['id'], 'rel' => null));
    echo $this->Html->meta(array('property' => 'og:description', 'type' => 'meta', 'content' => $course['Course']['summary'], 'rel' => null));
    echo $this->Html->meta(array('property' => 'og:image', 'type' => 'meta', 'content' => $courseimage_fb, 'rel' => null));
    echo $this->Html->meta(array('property' => 'og:type', 'type' => 'meta', 'content' => 'website', 'rel' => null)); ?>





在layouts文件夹的default.ctp文件中:





And in default.ctp file of layouts folder:

<?php echo $this->fetch('meta'); ?>





当我看到页面来源,然后是meta标签在页面正文中显示。



当我在Facebook上分享页面网址时,它会显示随机图像。有时正确,有时不正确的图像。页面中还有其他图像,如徽标和横幅。



这里有什么问题?我是否缺少facebook分享或任何其他元标记的任何javascript文件?请帮助。



when I see source of page, then meta tags are displaying in body of page.

When I share page url on Facebook, then it shows random images. Sometimes correct and sometimes incorrect image. There are other images in page like logo and banner.

What is wrong here? Whether I am missing any javascript file for facebook share or any other meta tag? Please help.

推荐答案

this-> Html-> meta(' description'
this->Html->meta('description',


course [' 课程'] [' summary']);

echo
course['Course']['summary']); echo


this-> Html-> meta(array(' property' => ' og:title'' type' => ' meta'' content' =>
this->Html->meta(array('property' => 'og:title', 'type' => 'meta', 'content' =>


这篇关于在cakephp子域名网站中添加Facebook og标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆