GithubHelp home page GithubHelp logo

elgg-opengraph's Introduction

Open Graph support for Elgg

The Open Graph protocol http://ogp.me/ is a way of providing rich content information for pages when shared on social networks.

This is quite powerful, but at the basic level it provides a way for content creators to control how the share stub looks when shared on networks like Facebook or Google +.

What this plugin does

This plugin adds Open Graph meta headers to your Elgg site (with reasonable defaults), and provides a framework for you to add specific open graph headers to object pages and specific URLS.

Installation

  • Place this plugin in mod/elgg-opengraph and activate it via your admin panel.
  • Optionally override the default open graph headers by providing a default array in settings.php, e.g.
	$CONFIG->site_opengraph = array(
		'og:image' => elgg_get_site_url() . 'mod/my_theme/graphics/site_logo.png',
		'og:site_name' => 'My site',
		'og:description' => "The Coolest site on tha interwebs!",
	);	

Usage

  • The default installation provides sensible basic defaults for everything other than og:image
  • Provide URL specific overrides by listening to the the 'header', 'opengraph' hook, e.g.
	elgg_register_plugin_hook_handler('header', 'opengraph', function ($hook, $handler, $return, $params){
           
            if (preg_match('/'.str_replace('/','\\/',elgg_get_site_url()).'mypage/', $params['url'])) {
                $return['og:description'] = 'New description here...';
                
                return $return;
            }
            
        });
  • To return details about a specific object type, add a hook for 'getbyurl', 'object', e.g.
	elgg_register_plugin_hook_handler('getbyurl', 'object', function ($hook_name, $entity_type, $return_value, $parameters) {
		global $CONFIG;

		if (preg_match("/".str_replace('/','\/', $CONFIG->wwwroot)."myobjecturl\/([0-9]*)/", $parameters['url'], $match)) {
	    
		    return get_entity((int)$match[1]);
	    
		}
	});

See

elgg-opengraph's People

Contributors

lowfill avatar mapkyca avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.