SPLINT Packages Wiki Downloads {} Blog Log In Sign Up

SPLINT

Packages

Wiki

Downloads

{} Blog

Log In


Sign Up

francis94c/og-tags

v0.0.1 2 0 - 0.0 0 {} 0 A3RT16543N


×

Are you sure you want to delete this package?

Users will no longer be able to intall this package if you do so.

Description

A Code Igniter library to easily generate and echo Open Graph Tags and other Social Meta Tags (Twitter, Facebook, etc.) in the header section of a HTML page.

README

License MIT Splint Identifier Splint Version Latest Release Commits

Open Graph Protocol

og-tags

A Code Igniter library to easily generate and echo Open Graph Tags and other Social Meta Tags (Twitter, Facebook, etc.) in the header section of a HTML page.

Installation

Download and Install Splint from https://splint.cynobit.com/downloads/splint and run the below from the root of your Code Igniter project.

splint install francis94c/og-tags

Usage

Package supports Descriptor Auto-loading

$this->load->package("francis94c/og-tags"); // Descriptor Auto-load.

$this->load->splint("francis94c/og-tags", "%og"); // Specific Loading

Helper Functions


Universal Function: og($name, $content)

$name: (string) : Open Graph Tag Name $content: (string) : Open Graph Tag Content

echo og("image", "http://example.com/logo.png");
// Returns <meta property="og:image" content="http://example.com/logo.png"/>

Read Values from a Config File : og_read_config($config_file_name, [$echo=false])

$config_file_name: (string) : The name of the config file you want it to load values from. This means you must reate a seperate php file in the application/config folder to hold og tag information. [$echo]: (boolean) : Optional, Whether to output the tags straight to the browser or return them as string. Default to false.

echo og_read_config("my_og_tags");
// Depending on the contents of your config file.
// Returns <meta property="og:title" content="A Title"/> \n <meta property="og:image" content="http://example.com/logo.png"/> \n ......

// Or
og_read_config("my_og_tags", true); // to echo directly to the browser.

The config file should contain something like the below.

$config["og_title"]            = "A Title";
$config["og_site_name"]        = "IMDb";
$config["og_audio"]            = "http://example.com/bond/theme.mp3";
$config["og_description"]      = "Sean Connery found fame and fortune as the suave, sophisticated British agent, James Bond.";
$config["og_determiner"]       = "the";
$config["og_locale"]           = "en_GB";
$config["og_locale:alternate"] = "fr_FR";
$config["og_image"]            = "http://example.com/rock.jpg";
$config["og_image:width"]      = "300";
$config["og_image:height"]     = "300";

All key names must be prefixed with 'og_'. Only scalar data type check applies to all elements here.

og_image($url)

echo og_image("http://example.com/logo.png");
// Returns <meta property="og:image" content="http://example.com/logo.png"/>

og_title($title)

echo og_title("A Title");
// Returns <meta property="og:title" content="A Title"/>

og_image_width($width)

Will Return "" if int is not supplied.

echo og_image_width(400);
// Returns <meta property="og:image:width" content="400"/>

og_image_height($height)

Will Return "" if int is not supplied.

echo og_image_height(200);
// Returns <meta property="og:image:height" content="200"/>

og_image_size($width, $height)

Will return only valid values (int) of the two parameters $width and $height.

echo og_image_size(500, 200);
// Returns <meta property="og:image:width" content="500"/> \n <meta property="og:image:height" content="200"/>

with from CynoBit