New version 0.9 has been released! Jun 16, 2015
×

File module

Description

File module helps you to create live editable file downloads on frontend.


Include

use yii\easyii\modules\file\api\File;


Public functions

object File::get( $id )
$id integer / string File identifier can be integer (id) or string (slug)

examples

File::get(1);
File::get('prices');
stdClass Object
(
    [id] => 1
    [title] => "File name"
    [slug] => "file-slug"
    [bytes] => 12345
    [size] => "12.35 KB"
    [file] => "/path/to/download/file"
    [link] => "<a href="/download/link">File name</a>"
    [seo_h1] => "Seo file title"
    [seo_title] => "Seo window title"
    [seo_keywords] => "seo, website, keywords"
    [seo_description] => "Seo description"
    [downloads] => 12
    [time] => 1623997077
    [date] => "Jun 18, 2021, 9:17:57 AM"
    [empty] => false
)
IF file with id == 1 or slug == 'prices' exists
stdClass Object
(
    [id] => ""
    [title] => ""
    [slug] => ""
    [bytes] => ""
    [size] => ""
    [file] => ""
    [link] => ""
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [downloads] => ""
    [time] => ""
    [date] => ""
    [empty] => true
)
IF file is not exist
stdClass Object
(
    [id] => ""
    [title] => "<a href="...">Create file</a>"
    [slug] => ""
    [bytes] => ""
    [size] => ""
    [file] => ""
    [link] => "<a href="...">Create file</a>"
    [seo_h1] => ""
    [seo_title] => ""
    [seo_keywords] => ""
    [seo_description] => ""
    [downloads] => ""
    [time] => ""
    [date] => ""
    [empty] => true
)
IF file is not exist and user logged in

array File::all( $options = [] )
$options array
  • pageSize (int) - files count on single page
  • where (array) - additional select condition

examples

File::all();
array of file objects

mixed File::last( $limit = 1 )
$limit integer Count of last files

examples

File::last(3);
file object IF limit == 1
array[3] of file objects IF limit > 1

string File::pages()
returns pagination html generated by yii\widgets\LinkPager widget.

object File::pagination()
returns yii\data\Pagination object.