Skip to content

Commit

Permalink
Merge pull request #51 from daloonik/master
Browse files Browse the repository at this point in the history
Added FB Open Graph and Twitter Card to template backend
  • Loading branch information
gsuez authored Jul 31, 2018
2 parents 103fedd + cb8ca29 commit 8054e41
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 120 deletions.
35 changes: 19 additions & 16 deletions html/com_content/article/default.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
Expand All @@ -20,41 +18,46 @@
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);

//Get some parameters from the template
$app = JFactory::getApplication();
$template = $app->getTemplate(true);
$tparams = $template->params;

// Check if associations are implemented. If they are, define the parameter.
$assocParam = (JLanguageAssociations::isEnabled() && $params->get('show_associations'));
JHtml::_('behavior.caption');

//Create FB Open Graph and Twitter Cards
if (isset($images->image_intro) and !empty($images->image_intro))
{
$timage= htmlspecialchars(JURI::root().$images->image_intro);
$timage = htmlspecialchars(JURI::root().$images->image_intro);
}

elseif (isset($images->image_fulltext) and !empty($images->image_fulltext))
{
$timage= htmlspecialchars(JURI::root().$images->image_fulltext);
$timage = htmlspecialchars(JURI::root().$images->image_fulltext);
}
else
{
$timage= 'https://www.masterbootstrap.com/images/217x196xprofessortocat-compressor.png.pagespeed.ic.F75ysx_X8Q.webp';
$timage = '';
}
$doc =& JFactory::getDocument();
$doc->addCustomTag( '
<meta name="twitter:title" content="'.$this->escape($this->item->title).'">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@masterbootstrap">
<meta name="twitter:creator" content="masterbootstrap">
<meta name="twitter:site" content="'.$tparams->get('twittersite') .'">
<meta name="twitter:creator" content="'.$tparams->get('twittercreator') .'">
<meta name="twitter:url" content="'.str_replace('" ','&quot;',JURI::current()).'">
<meta name="twitter:description" content="'.strip_tags($this->item->introtext).'">
<meta name="twitter:description" content="'.mb_strimwidth(strip_tags($this->item->introtext),0,100, " ...").'">
<meta name="twitter:image" content="'.$timage.'">
<meta property="og:title" content="'.$this->escape($this->item->title).'"/>
<meta property="og:type" content="article"/>
<meta property="og:email" content="[email protected]";/>
<meta property="og:url" content="'.str_replace('" ','&quot;',juri::current()).'">
<meta property="og:image" content="'.$timage.'"/>
<meta property="og:site_name" content="MasterBootStrap"/>
<meta property="fb:admins" content="xxxxxxxxxxx"/>
<meta property="og:description" content="'.strip_tags($this->item->introtext).'"/>
<meta property="og:title" content="'.$this->escape($this->item->title).'" />
<meta property="og:type" content="article" />
<meta property="og:url" content="'.str_replace('" ','&quot;',juri::current()).'" />
<meta property="og:image" content="'.$timage.'" />
<meta property="og:site_name" content="'.$tparams->get('ogsitename') .'"/>
<meta property="fb:admins" content="'.$tparams->get('FBadmins') .'" />
<meta property="fb:app_id" content="'.$tparams->get('FBapp_id') .'" />
<meta property="og:description" content="'.mb_strimwidth(strip_tags($this->item->introtext),0,100, " ...").'" />
');
//End FB Open Graph and Twitter Card

Expand Down
79 changes: 0 additions & 79 deletions html/com_content/article/default_links.php

This file was deleted.

58 changes: 33 additions & 25 deletions templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@
</fieldset>
<!-- LOGO-->
<fieldset name="logo" type="upload_func" label="Logo">
<field name="logo_file" type="media" label="Select your logo:"></field>
<field name="logo_link" type="text" label="Logo link:" description="Example: http://www.masterbootstrap.com" default="index.php"></field>
<field name="logo_width" type="text" label="Logo width:" description="Example: 90" default="173"></field>
<field name="logo_height" type="text" label="Logo height:" description="Example: 90" default="26"></field>
<field name="logo_file" type="media" label="Select your logo:"></field>
<field name="logo_link" type="text" label="Logo link:" description="Example: http://www.masterbootstrap.com" default="index.php"></field>
<field name="logo_width" type="text" label="Logo width:" description="Example: 90" default="173"></field>
<field name="logo_height" type="text" label="Logo height:" description="Example: 90" default="26"></field>
</fieldset>
<!-- GOOGLE FONTS-->
<fieldset name="Font" label="Fonts">
<field name="googleFont" type="radio" class="btn-group btn-group-yesno" default="0" label="Google Font for Headings" description="Google Font for H1, H2, H3, etc">
<field name="googleFont" type="radio" class="btn-group btn-group-yesno" default="0" label="Google Font for Headings" description="Google Font for H1, H2, H3, etc">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="googleFontName" class="" type="text" default="Open+Sans" label="Font Name" description="Font Name" showon="googleFont:1" />
<field name="googleFontName" class="" type="text" default="Open+Sans" label="Font Name" description="Font Name" showon="googleFont:1" />
<field name="bodyFont" class="btn-group btn-group-yesno" type="radio" default="0" label="Google Font for Body" description="Google Font for Body">
<option value="1">JYES</option>
<option value="0">JNO</option>
Expand All @@ -117,26 +117,34 @@
<option value="0">JNO</option>
</field>
<field name="navigationFontname" type="text" default="Open+Sans" label="Font Name" description="Font Name" showon="navigationFont:1"/>
</fieldset>
</fieldset>
<!-- LAYOUT -->
<fieldset name="Layout" label="Layout Options">
<field name="layout" type="radio" class="btn-group" default="full" label="Layout" description="Select Full Layout or Boxed Layout" >
<option value="full">Full Layout</option>
<option value="boxed">Boxed Layout</option>
</field>
</fieldset>
<fieldset name="Layout" label="Layout Options">
<field name="layout" type="radio" class="btn-group" default="full" label="Layout" description="Select Full Layout or Boxed Layout" >
<option value="full">Full Layout</option>
<option value="boxed">Boxed Layout</option>
</field>
</fieldset>
<!-- PATTERN -->
<fieldset name="Pattern" label="Pattern Options">
<field name="pattern" type="list" default="default" label="Pattern" description="Select Pattern for Boxed Layout" >
<option value="default">Pattern Default</option>
<option value="1">Pattern 1</option>
<option value="2">Pattern 2</option>
<option value="3">Pattern 3</option>
<option value="4">Pattern 4</option>
<option value="5">Pattern 5</option>
<option value="6">Pattern 6</option>
</field>
</fieldset>
</fields>
<fieldset name="Pattern" label="Pattern Options">
<field name="pattern" type="list" default="default" label="Pattern" description="Select Pattern for Boxed Layout" >
<option value="default">Pattern Default</option>
<option value="1">Pattern 1</option>
<option value="2">Pattern 2</option>
<option value="3">Pattern 3</option>
<option value="4">Pattern 4</option>
<option value="5">Pattern 5</option>
<option value="6">Pattern 6</option>
</field>
</fieldset>
<!-- OPEN GRAPH -->
<fieldset name="fbopengraph" label="Open Graph">
<field name="twittersite" type="text" default="@masterbootstrap" label="@username of website" description="@username of website" />
<field name="twittercreator" type="text" default="@masterbootstrap" label="@username of content creator" description="@username of content creator" />
<field name="ogsitename" type="text" default="MasterBootStrap" label="Overall site name" description="Overall site name" />
<field name="FBadmins" type="text" default="USER_ID" label="Facebook Admin Id" description="Facebook Admin Id" />
<field name="FBapp_id" type="text" default="APPID" label="Facebook App Id" description="Facebook App Id" />
</fieldset>
</fields>
</config>
</extension>

0 comments on commit 8054e41

Please sign in to comment.