2017 © Pedro Peláez
 

yii2-extension yii2-microformats

Yii2 Widget to generate microformats2 from model data

image

beastbytes/yii2-microformats

Yii2 Widget to generate microformats2 from model data

  • Wednesday, August 5, 2015
  • by BeastBytes
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

Microformats2 Generator for Yii2

This extension is a Yii2 Widget to generate microformats from model data; also included is a Formatter class for formatting of WGS84 coordinates., (*1)

For license information check the LICENSE-file., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist beastbytes/yii2-microformats

or add, (*5)

"beastbytes/yii2-microformats": "~1.0.0"

to the require section of your composer.json., (*6)

Usage

Use this extension in a view in a similar way to yii\widgets\DetailView (it's a child class of DetailView)., (*7)

Let's generate an "h-card" from a user model - $user - that has the following relations:, (*8)

  • profile - that stores the user's name
  • address - for the user's address
  • phone - for the user's phone number

In the view:, (*9)

echo Microformat::widget([
    'microformat' => 'h-card', // name of the microformat
    'model' => $user, // the model that provides the data
    'attributes' => [ / the attributes array specifies the microformat properties
        'p-name:profile.name', // get the user's name from the profile relation
        'p-email',
        'p-tel:phone.value',        
        [ // Additional markup that is not a microformat property
            'value' => 'Address',
            'template' => '<div class="h-card__title">{value}</div>' // with it's own template
        ],
        [
            'property' => 'p-adr',
            'microformat' => 'h-adr, // Markup the address with an embedded h-adr microformat
            'model' => $user->address, // we can specify a new model for embedded microformats; if not given the parent microformat model is used
            'template' => '<div {options}>{value}</div>', // a new template for h-adr
            'attributes' => [
                'p-street-address', // fetch data from $user->address->street_address
                'p-locality',
                'p-region',
                'p-postal-code',
                [
                    'property' => 'p-geo',
                    'microformat' => 'h-geo',
                    'template' => '<div><span>{label}</span><data {options} value="{rawValue}">{value}</data></div>',
                    'formatter' => [ // use the included formatter for latitude and longitude
                        'class' => '\\beastbytes\\microformats\\Formatter',
                        'coordinateFormat' => '%02d %02.6f h'
                    ],
                    'attributes' => [
                        'property' => 'p-latitude:latitude:latitude', // microformat property:model attribte:format
                        'property' => 'p-longitude:longitude:longitude'
                    ]
                ]
            ]            
        ]
    ]
]);

See the source code for more configuration details., (*10)

The Versions

05/08 2015

dev-master

9999999-dev

Yii2 Widget to generate microformats2 from model data

  Sources   Download

BSD-3-Clause

The Requires

 

by Chris Yates

yii2 widget microformats microformats2 microformat

26/07 2015

v1.0.0

1.0.0.0

Yii2 Widget to generate microformats2 from model data

  Sources   Download

BSD-3-Clause

The Requires

 

by Chris Yates

yii2 widget microformats microformats2 microformat

26/07 2015

v0.1

0.1.0.0

Yii2 Widget to generate microformats2 from model data

  Sources   Download

BSD-3-Clause

The Requires

 

by Chris Yates

yii2 widget microformats microformats2 microformat