CMSEnergizer

CMSEnergizer

CMSEnergizer

Thursday, 30 November 2017 03:18

CMSE Video Field

Learn how to setup the field in your list of Joomla custom fields and apply to an article

Thursday, 30 November 2017 03:17

CMSE Shortcodes Editor Plugin

Learn how to enable functions included and how to easily insert content shortcodes

Thursday, 30 November 2017 03:14

CMSE Latest Posts

Learn the basic and advanced setup methods to deliver intriguing article excerpt displays

Thursday, 30 November 2017 01:52

CMSE Custom Fields Plugin

Learn the basic installation, configuration and custom article formatting methods

Friday, 27 October 2017 23:19

JA Elastica by Joomlart

Friday, 27 October 2017 22:43

GK Magazine

Friday, 27 October 2017 22:34

GK Portfolio

Friday, 27 October 2017 20:58

Forte by Shape5

Friday, 27 October 2017 18:14

nuModusVersus

The facebook gods have removed the ability to alter data scraped from pages, due to abusers who do so to mislead viewers. While there were evil doers wrecking the damn thing, there are good reasons why one would want the post title, text and even image to differ from the actual post.

Facebook Live Chat for Joomla

The art of marketing within discussion forums

 

Cases to alter social meta data

  • A post is considered NSFW (that's shorthand for the geek speak 'not safe for work') so Facebook puritans may punish you for it with bans. A softer image is needed for the post at FB and the title may need a few characters to make words only imply the meaning. So if the title and text includes 'fuck that dude', you will need to make it 'f&4k that dude' at the social spot.
  • A product post may literally state "My product is better than his" but you don't want to seem arrogant at the FB, so you want the title to read "Only the best is worthy for you"

...and so on.

The How to

Note that the excellent custom field system included with K2 will do the task very well, but this is about doing it with overrides and coding. This guide assumes you know how to use Joomla's template override system.

A default post will output at Facebook with the exact title and text as published with the page as the following image shows

before social meta alteration

After the modifications, the same post can be altered to output with title and text that differs from that of the page

new facebook scrape

 

  1. Create an override of administrator/components/com_k2/views/item/tmpl/default.php
  2. Edit the file at the line with string <h3><?php echo JText::_('K2_METADATA'); ?></h3>
  3. Add the block of code for the post title within the UL set. This will appear within the MetaData fieldset, above the meta description text area
    <li>
    	<div class="paramLabel">
    		<label>Social Net Post Title</label>
    	</div>
    	<div class="paramValue">
    		<input type="text" name="socialtitle" value="<?php echo $this->row->socialtitle; ?>" />
    	</div>
    </li>
    


    The output
    k2 social meta

  4. Alter the #__k2_items table to add the socialtitle column
    ALTER TABLE hex_k2_items
    ADD socialtitle VARCHAR(255) NOT NULL
    
  5. Create a K2 custom template by duplicating the default at components/com_k2/templates. Name the directory
  6. Edit item.php and add the following within the php block at the top
    $document = JFactory::getDocument();
    $metadesc = $document->getMetaData('description');
    if( !empty($this->item->metadesc) ) {
        $metadesc = $this->item->metadesc;
    }else{
        $metadesc = strip_tags(substr($this->item->introtext, 0, 150));
    }
    $document->setMetaData('og:description', $metadesc, 'property');
    
    // if social title is set, remove default title and write new title
    if( !empty($this->item->socialtitle) ) {
        unset($document->_metaTags['name']['og:title']);
        $document->setMetaData('og:title', $this->item->socialtitle, 'property');
    }
    
  7. Test

 

Note that you should always confirm the output by checking the FB scrape debugger at https://developers.facebook.com/tools/debug/og/object/

Page 1 of 8
Copyright © 2017 CMSEnergizer.com. All Rights Reserved.
This website is powered by the Joomla!©™ 3 Website Framework | File download and article manager component by K2 | Advanced Module Manager and Modules Anywhere by NoNumber Elements | Website hosting and development by WebsiteDons

CMSEnergizer.com is owned and operated by Emuzement Net Inc, 4532 West Kennedy Blvd. Ste 180 33609 Tampa, Florida USA