izica/bitrix-seo-tools

2.1.1 2023-04-09 00:58 UTC

This package is auto-updated.

Last update: 2024-09-09 04:19:46 UTC


README

这是一个用于处理不同类型元标签的库。包括 Facebook、Twitter、Google、Vkontakte 和常规元标签。支持管理自定义元标签。默认情况下,标签来自 Bitrix 的 SEO 功能。当页面上存在以下 SEO 功能时

$APPLICATION->SetPageProperty("title", "Заголовок");
$APPLICATION->SetPageProperty("description", "desc");

库会自动获取并连接 Facebook、Twitter、Google、Vkontakte 的标签。

安装

composer require izica/bitrix-seo-tools

对于第一次在 Bitrix 上使用 composer 的用户。库通常安装在 local/php_interface (cd local/php_interface) 中。接着在 local/php_interface/init.php 中添加以下内容:

require_once 'vendor/autoload.php';

header.php

    <head>
        <?$APPLICATION->ShowHead();?>
        <?BitrixSeoTools::showMeta()?>
        <title><?$APPLICATION->ShowTitle();?></title>
    </head>

支持

  • OpenGraph(Facebook 等)
  • GooglePlus
  • Twitter
  • Bitrix API

使用方法

BitrixSeoTools::title('Page Title');
BitrixSeoTools::description('Page Description');
BitrixSeoTools::keywords('page, bitrix, seo');
BitrixSeoTools::image('someurl/image.jpg');
BitrixSeoTools::title('Page Title')
	->description('Page Description')
	->keywords('page, bitrix, seo')
	->image('someurl/image.jpg');

具体类型标签

BitrixSeoTools::opengraph()
    ->title('Title')
    ->description('Description')
    ->image('image.jpg');

自定义标签

BitrixSeoTools::custom()
    ->add(['charset' => 'utf-8'])
    ->add([
        'http-equiv' => 'Content-Type'
        'content' => 'text/html; charset=UTF-8'
    ]);

生成分享

<a href="<?=BitrixSeoTools::share()->facebook();?>" target="_blank">Facebook</a>

类描述

  • BitrixSeoTools

    • title
    • description
    • image
    • url
    • keywords
    • robots
    • googleplus:GooglePlus
    • opengraph:OpenGraph
    • twitter:Twitter
    • bitrix:Bitrix
    • custom:Custom
    • share:Share
  • OpenGraph

    • title
    • description
    • image
    • url
  • GooglePlus

    • title
    • description
    • image
  • Twitter

    • title
    • description
    • image
  • Bitrix

    • title
    • description
    • url
    • keywords
    • robots
  • Custom

    • add
  • Share

    • vkontakte
    • facebook
    • odnoklassniki
    • twitter