hofff/contao-shariff

Provide a neat way to make shariff usable from custom modules/content elements.

discordier opened this issue · 1 comments

It would be nice if you would provide lean and slick wrapper code to allow other developers to include shariff within their modules.

One way of including shariff would be to have only the shariff code within a template that can be imported from any other template.

I think of something like:

class MyModule
{
  public function compile()
 {
    $this->Template->shariff = array(
      'services' => array('twitter', 'googleplus'),
      // various settings for shariff.
    );
 }
}

The custom template of the user/another developer:

<!-- ... custom template code... -->
<?php $this->insert('hoff_shariff', $this->shariff); ?>
<!-- ... even more template code ... -->

The content of hoff_shariff.html5 would be something like:

<?php 
$GLOBALS['TL_CSS']['shariff.css'] = 'system/modules/hofff_shariff/assets/css/shariff.min.css';
$GLOBALS['TL_BODY']['shariff.js'] = '<script src="system/modules/hofff_shariff/assets/js/shariff.min.js"></script>';
?>

<div class="shariff"
      data-services="<?php echo specialchars(json_encode(deserialize($this->services, true))); ?>"
<?php if(strlen($this->url)): ?>
      data-url="<?php echo specialchars($this->url); ?>"
<?php endif; ?>
<?php if(strlen($this->referrer_track)): ?>
      data-referrer-track="<?php echo specialchars($this->referrer_track); ?>"
<?php endif; ?>
<?php if(strlen($this->twitter_via)): ?>
      data-twitter-via="<?php echo specialchars($this->twitter_via); ?>"
<?php endif; ?>
      data-orientation="<?php echo specialchars($this->orientation); ?>"
      data-theme="<?php echo specialchars($this->theme); ?>"
  ></div>

ist umgesetzt, kommt im nächsten release