2017 © Pedro Peláez
 

library zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

image

ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  • Wednesday, June 24, 2015
  • by leodido
  • Repository
  • 5 Watchers
  • 7 Stars
  • 185 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

HangerSnippet

Travis Packagist License Scrutinizer Scrutinizer Coverage, (*1)

This ZF2 Module aims to provide a fast way to configure and append code snippeds for JS libraries., (*2)

Rationale

Often happens to have to set up a Javascript library and many times it would be nice to have a place where you can configure them and perhaps with the ability to override the configuration rather than throw them in the view., (*3)

Installation

Via Composer

Add ripaclub/zf2-hanger-snippet to your composer.json, (*4)

{
   "require": {
       "ripaclub/zf2-hanger-snippet": "~1.0.6"
   }
}

Setup

In your layout before the body closing tag, (*5)

<?php echo $this->hangerSnippet(); ?>

Optionally, if you need to add more placements:, (*6)

<?php echo $this->hangerSnippet()->render('placementName'); ?>

Configuration

return [
    'hanger_snippet' => [
        'enable_all' => true, //if not specified true by default
        'snippets' => [
            'snippet-name' => [
                'config_key'  => '', // Config node in the global config, if any, retrivied data will be merged with values then passed to the template
                'template'    => '', // Template script path, if not specified 'hanger-snippet/snippet-name' will be used
                'placement'   => '', // Placement identifier, if not specified the default placement will be used
                'enabled'     => true, // When not specified 'enable_all' value will be used
                'values' => [
                    // Other values for the template
                ],
            ],
        ],
    ],
];

Do not forget to add HangerSnippet module to you application.config.php file., (*7)

'modules' => [
        // ...
        'HangerSnippet',
        'Application',
],

Built-in snippets

Google Analytics

Configuration:, (*8)

return [
    'ga' => [
        'monitoring_id' => 'UA-XXXXXXXX-X',
        'domain'        => 'yourdomain.com',
        'anonymize_ip'  => false, // refer to https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#anonymizeip for more information
        'options' => [
            'siteSpeedSampleRate' => 1,
            'sampleRate' => 100
            // refer to https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference for more options
        ],
    ],

    'hanger_snippet' => [
        'snippets' => [
            'google-analytics' => [
                'config_key' => 'ga', // the config node in the global config, if any
                'values' => [
                    // other values for the template
                ],
            ],
        ],
    ],
];

Facebook JavaScript SDK

Configuration:, (*9)

return [
    'facebook' => [
           'appId' => '...',
    ],

    'hanger_snippet' => [
        'snippets' => [
            'facebook-sdk' => [
                'config_key' => 'facebook', // the config node in the global config, if any
                'values' => [
                    'async' => false,
                    'status' => true,
                    'xfbml'  => true,
                    'version' => 'v2.2',
                ],
            ],
        ],
    ],
];

Google no CAPTCHA reCAPTCHA

Configuration:, (*10)

return [
    'grecaptcha2.0' => [
        'uri' => 'https://www.google.com/recaptcha/api.js'
        // Optional API parameters - see https://developers.google.com/recaptcha/docs/display
        'parameters' => [
            'render' => 'onload',
            // 'hl' => '...',
            // 'onload' => '...',
        ],
    ],

    'hanger_snippet' => [
        'snippets' => [
            'google-nocaptcha-recaptcha' => [
                'config_key' => 'grecaptcha2.0', // the config node in the global config, if any
                'values' => [
                    'sitekey' => '',
                    // Optional configurations - see https://developers.google.com/recaptcha/docs/display
                    'theme' => 'light',
                    'type' => 'image',
                    'callback' => '...',
                    'expiredCallback' => '...'
                ],
            ],
        ],
    ],
];

The placement of Google ReCaptcha snippet, unlike the others, needs to be specified (it can not be simply appended to the page)., (*11)

To place this snippet where you need it ..., (*12)

<?php echo $this->hangerSnippet()->render('google-nocaptcha-recaptcha'); ?>
NOTE

The string google-nocaptcha-recaptcha is the default name of the placement for this snippet (see module.config.php)., (*13)


Analytics, (*14)

The Versions

24/06 2015

dev-master

9999999-dev https://github.com/ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

javascript zf2 zend framework js facebook snippets google analytics snippet universal analytics appender hanger append google no recaptcha google recaptcha 2.0

22/06 2015

dev-develop

dev-develop https://github.com/ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

javascript zf2 zend framework js facebook snippets google analytics snippet universal analytics appender hanger append google no recaptcha google recaptcha 2.0

05/06 2015

v1.0.6

1.0.6.0 https://github.com/ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

javascript zf2 zend framework js facebook snippets google analytics snippet universal analytics appender hanger append google no recaptcha google recaptcha 2.0

06/03 2015

v1.0.5

1.0.5.0 https://github.com/ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

javascript zf2 zend framework js facebook snippets google analytics snippet universal analytics appender hanger append

26/01 2015

v1.0.4

1.0.4.0 https://github.com/ripaclub/zf2-hanger-snippet

A module to attach HTML/JS snippets into a ZF2 application

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

javascript zf2 zend framework js facebook snippets google analytics snippet universal analytics appender hanger append