# Content

# Install

composer require contributte/social
1

# Facebook

Collection of facebook components for Nette 2.4.0.

# Plugins

Plugin Source Docs
Like Button source doc
Share Button source doc
Send Button source doc
Embedded Posts source doc
Embedded Videos source doc
Follow Button source doc
Comments source doc
Page Plugin source doc

# Deprecated

Plugin Source Docs
Activity Feed source doc
Recommendations Feed source doc
Like Box source doc
Facepile source doc

# Usage

# Presenter

use Contributte\Social\Facebook\LikeButton;
use Contributte\Social\Facebook\Script;

protected function createComponentLikeButton()
{
    $button = new LikeButton();
    $attrs = $button->getAttributes();

    // URL - manually
    $attrs->add('data-url', $this->link('Home:default'));

    // URL - current
    $attrs->add('data-url', $this->link('//this'));

    // Add other attributes

    $attrs->add('data-layout', $button::LAYOUT_BUTTON_COUNT);
    // OR
    $attrs->data('layout', $button::LAYOUT_BUTTON_COUNT);

    return $button;
}

protected function createComponentScript()
{
    $script = new Script();
    $script->setApiVersion("v2.6");
    $script->setAppId(123456);

    return $script;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# Template

You have to display JavaScript code.

{control likebutton}
{control script}
1
2

# Google +1

# Settings

Type Field Default Setter/Getter Info
string $size standard yes/yes
string $annotation inline yes/yes inline/bubble/none
string $callback NULL yes/yes
string $url NULL yes/yes
int $mode default yes/yes default/explicit/dynamic
int $width 300 yes/yes
string $lang cs yes/yes
Html $elementPrototype div class="g-plusone" yes/yes html prototype
array $properties [] yes/yes

# Factory

use Contributte\Social\Google\PlusOne;

protected function createComponentPlusone() {
    $button = new PlusOne();
    $button->setMode($button::MODE_DEFAULT);
    $button->setUrl('www.google.com');

    return $button;
}
1
2
3
4
5
6
7
8
9
/** @var Contributte\Social\Google\IPlusOneFactory @inject */
public $plusOneFactory;

protected function createComponentPlusone() {
    $button = $this->plusOneFactory->create();
    $button->setMode($button::MODE_DEFAULT);
    $button->setUrl('www.google.com');

    return $button;
}
1
2
3
4
5
6
7
8
9
10

# Template

# Render javascript

Place before </body> or </head>.

{control plusone:js}

# Render button

Button #1: {control plusone}

Button #2: {control plusone, $url}

Button #3: {control plusone, 'www.seznam.com'}

# Google Analytics Campaign Maker

Small utility for creating GA accepted parameters to url.

# Parameters

  • source
  • medium
  • campaign
  • term
  • content

# Usage

use Contributte\Social\Google\Analytics\Campaign;

// Source, medium, campaign
$campaign = new Campaign('newsletter', 'website', 'april13');
$this->link('Card:detail', $campaign->build());

// Source, medium, campaign, term, content
$campaign = new Campaign('newsletter', 'website', 'april13', 'term1', 'content');
$this->link('Product:detail', $campaign->build());

// Factory (same args as previous)
$link = Campaign::create('newsletter', 'website', 'april13');
$this->link('Foto:detail', $link);
1
2
3
4
5
6
7
8
9
10
11
12
13

# Twitter

# TweetButton

# Settings

Type Field Default Setter/Getter Info
string $url NULL yes/yes
string $href https://twitter.com/share yes/yes
string $via NULL yes/yes
string $text NULL yes/yes
string $related NULL yes/yes
string $count vertical yes/yes none/vertical/horizontal
string $counturl NULL yes/yes
array $hashtags [] yes/yes
string $size medium yes/yes medium/large
bool $dnt FALSE yes/yes
string $lang cs yes/yes
Html $elementPrototype a yes/yes html prototype
string $elementText Tweet yes/yes
array $properties [] yes/yes

# Helpers

  • setShareButton($text)
  • setMentionButton($mention)
  • setHashtagButton($hashtag)

# Factory

# config.neon
services:
    - Contributte\Social\Twitter\ITweetButtonFactory
1
2
# Presenter
use Contributte\Social\Twitter\TweetButton;

/**
  * @return TweetButton
  */
protected function createComponentPlusone() {
    $button = new TweetButton();
    $button->setShareButton('www.google.com');
    return $button;
}
1
2
3
4
5
6
7
8
9
10
/** @var Contributte\Social\Twitter\ITweetButtonFactory @inject */
public $twitterFactory;

/**
  * @return TweetButton
  */
protected function createComponentTwitter() {
    $button = $this->twitterFactory->create();
    $button->setShareButton('www.google.com');

    return $button;
}
1
2
3
4
5
6
7
8
9
10
11
12

# Template

# Render javascript

Place before </body> or </head>.

{control twitter:js}

# Render button

Button #1: {control twitter}

Button #2: {control twitter, $url}

Button #3: {control twitter, 'www.seznam.com'}