Recent Topics

1 Mar 04, 2013 10:50    


I'm trying to implement "twitter card" support in my skins. For this, it is necessary to have a meta tag "twitter:description" with a short excerpt from the post. This is what I tried so far, added to display_init() in _skin.class.php:

add_headline('<meta itemprop="name" content="'.format_to_output( $Item->title, 'htmlattr' ).'">');

Unfortunately, this doesn't work, because $Item->title() has no return value, but uses echo instead.

What would be the correct way to implement this?


2 Mar 05, 2013 18:55

You can hardcode your meta header into the header of your skin or one of your skin templates.

For doing this, it makes no sense to modify any file that is outside of /skins/your_skin/

3 Mar 05, 2013 19:10

what's wrong with content="'.$Item->title'" ?

4 Mar 05, 2013 21:21

Adding a few lines into your skin's _skin.class.php is not much of a hack and there is no easy way out for regular users.It's not like anyone is going to create a plugin to add a few lines of modif.

To overcome this, maybe we might add a blank custom_functions.php with a few notes and desc. ?

/* In order not to lose the changes you make in _skin.class.php and any other skin files for that matter, please add your functions & customizations in this file.
require_css( 'custom.css', true ); // additional css file
require_js( 'script.js',true ); // additional js
add_headline('<meta property="name" content="value">');

@fplanque wrote earlier:

Note: we don't recommend to use code hacks at any time:
@tilqicom : I believe @christophoros's only issue is that he's not adding the code in the right place.

5 Mar 05, 2013 23:17

Sorry I misread the original post. changing _skin.class.php in a custom skin is perfectly fine.

Editing the header file of the skin is just another option.

@christophoros try Item->get_title() instead:

	add_headline('<meta itemprop="name" content="'.$Item->get_title( array( 'format' => 'htmlattr' ) ).'">');

6 Feb 12, 2015 17:17

Hi fplanque,

Is there a chance to integrate Twitter Cards in b2e, in a way that meta tag description shows dynamically the description of the actual addressed page?

Thanks in advance

7 Feb 14, 2015 01:01

It's fairly easy for you to add twitter cards to your skin.

It's a bit tricky to do this by default because there are many different types of twitter cards and most users don't want any by default.

8 Feb 19, 2015 19:21

Open your _skin.class.php find function display_init() . If it's not there you can add it.

function display_init()
		global $Blog, $Item,$Chapter;

		if( isset($Item) && ! empty($Item) ) {
			// if we are on a post / page
			$id = $Item->ID;
			$tw_desc = $Item->excerpt;
		else if ( isset($Chapter) && ! empty($Chapter) ) {
			//if we are on category 
			$tw_desc = $Chapter->description;
		else {
			// Just in case, for everything else.	
			$tw_desc = $Blog->longdesc;
		add_headline('<meta name="twitter:description" content="'.$tw_desc.'" />');


Form is loading...