Import Methods



( ZN >= 1.0.0 )

This library is used to include entity files such as view , js , css , font . The libraries do not need to be included because of the ZN Framework's auto-installer feature .

 

 

# Import Priority


The files are usually included in the corresponding directories in the External /  and Projects / directory. But if there are files of the same name that you need to know here, first of all, what sort of file will be included. This sort is;

1 - Projects
2 - External

like this. The file upload priority is Internal. If the file does not exist here, the External (external) index is looked at this time. If the file does not exist in every 2 directories, no inclusion is done.

 

 

# Methods


this usable ( Bool $ usable = true )
this data ( Array $ data )
Mixed view ( String $ page , Array $ data = NULL , Bool $ contents = false )
Mixed template ( String $ page , Array $ data = NULL , Bool $ contents = false )
String font ( String ... $ fonts )
String style ( String ... $ styles )
String script ( String ... $ scripts )
Mixed something ( String $ page , Array $ data = NULL , Bool $ contents = false )
this recursive ( Bool $ recursive = true )
Mixed theme ( Mixed $ theme , Bool $ recursive = false , Bool $ contents = false )
Mixed plugin ( Mixed $ plugin , Bool $ recursive = false , Bool $ contents = false )
Mixed handload ( String ... $ args )
String masterPage ( Array $ data , Array $ head )

 

 

# Usable ( ZN >= 3.0.0 )


It allows the contents of the included files to be transferred to the changelog. So why do you need such a use? Sometimes it is necessary to send the contents of one page to another page as data. Especially if you design your own masterpage'i it allows you to send the data to the page set as the page contents masterpage. It does not have to be used because it is an optional method .

Parameters

Bool $ usable = true Can you transfer it?
return this

Use of

File: Projects / ProjectDirectory / Controllers / home.php
<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        $content = Import::usable()->view('content');
        $styles  = Import::usable()->styles('mystyle', 'sitestyle');
        
        View::content($content)->styles($styles);
    }
}

 

 

# Data ( ZN >= 3.0.0 )


It is used to send data to included PHP pages. It does not have to be used because it is an optional method .

Parameters

Array $ data The sender string is sent to the view pages.
return this

It is used in place of parameter 2 of the following methods .

Use of

File: Controllers / home.php
<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        $data = 
        [
            'content' => Import::usable()->view('content'),
            'styles'  => Import::usable()->styles('mystyle', 'sitestyle')
        ];

        Import::data($data)->view('home');
    }
}

 

 

# View ( ZN >= 0.0.1 )


It is used to include or invoke the pages in the Views / directory.

Parameters

String $ Page Views / path of view page to be called from directory. There is no need to add a .php or .wizard extension.
Array $ data = NULL The display sequence to be sent.
Bool $ usable = false Can you transfer the content of the view?
return Mixed

Use of

File: Controllers / home.php
<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        Import::view('home');
    }
}
Data Sending

Data transmission is done with parameter 2 . This parameter should be sent to an array in which the data to be sent in the key => value form is sent.

<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        $content = Import::usable()->view('content');
        $styles  = Import::usable()->styles('mystyle', 'sitestyle');

        Import::view('home',
        [
            'content' => $content,
            'styles'  => $styles
        ]);
    }
}
Variable Transferability

For parameter transfer, parameter 3 must be set to true or usable ( true ) method must be used. If 3 using parameters and you do not send the data 2 parameterNULL or [] you need to set it.

<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        $content = Import::view('content', NULL, true);

        Import::view('home',
        [
            'content' => $content
        ]);
    }
}

 

 

# Template ( ZN >= 0.0.1 )


This method is similar to the use of view, making calls from 2 arrays. According to the call priority, these directories are as follows.

File: Projects / Any / Resources / Templates /
File: External / Resources

Generally, these directories contain html tables, schemas, forms with .phpextensions .

Parameters

String $ Page The path to the template file to be called from the Resources / Templates / directory. There is no need to add a .php or .wizard extension.
Array $ data = NULL The display sequence to be sent.
Bool $ usable = false Can you transfer the content of the view?
return Mixed

Use of

File: Controllers / home.php
<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {  
        $templateData  =


        [
            'subject' => 'Example Subject',
            'message' => 'Example Message'      
        ];
      
        $emailTemplate = Import::template('MyEmailTemplate', $templateData, true);
        
        View::emailTemplate($emailTemplate);
    }
}

 

 

# Font ( ZN >= 0.0.1 )


Resources / Fonts /  is used  to include font files added to the Resources / Themes / Any / directories if this directory is not used. Supported fonts are SVG, WOFF, OTF, TTF, EOT fonts. If desired, the settings file in the Settings / Expressions.php file'differentFontExtensions' => [] Different font types can be specified that are supported by the setting.

Note: For version 5.5 and later , the Themes / directory will be used instead of Fonts / directory . Fonts / will not be included in the new versions. Fonts / directory usage will continue, however, to avoid backward compatibility issues .

Parameters

Mixed $ Args ... The path to the font file to be called from Resources / Themes / .
return Mixed

Use of

Import::font('Elips');

If you want to include multiple font files in the same folder, we use it in the following way. More than one font can be included at the same time.

Import::font('Elips', 'Abode', 'Secrcode/secrcode');
Variable Transferability

If you want to import the imported style file as a variable, the last parameter must be entered as true or the usable () method should be used.

$font = Import::font('Elips', 'Abode', 'Secrcode/secrcode', true);
// Ya da
$font = Import::usable()->font('Elips');
Application

Let's examine it in a simple code to better understand usage.

File: Controllers / home.php
<?php namespace Project\Controllers;

use Import;

class Home extends Controller
{
    public function main()
    {
        Import::font('Akrobat/Black');
    }
}
View File: Views / home / main.php
<div style="font-family:AkrobatBlack">Font Example</div>

 

 

# Style ( ZN >= 0.0.1 )


Resources / Styles /  is used to include style files created in the Resources / Themes / Any / directories if this directory is not used. It is possible to include more than one file at the same time.

Note: For version 5.5 and later , the Themes / directory will be used instead of the Styles / directory . Styles / will not be in new releases. Styles / directory usage will continue, however, to avoid backward compatibility issues .

Parameters

Mixed $ Args ... The path to the css file to be called from the Resources / Themes / directory .
return Mixed

Use of

Import::style('site');

If you want to include multiple styles in the same file, we use it in the following way.

Import::style('site', 'contact', 'panel');
Variable Transferability

If you want to import the imported style file as a variable, the last parameter should be set to true .

$style = Import::style('site', 'contact', 'panel' , true);

 

 

# Script ( ZN> = 0.0.1 )


Resources / Scripts /  is used to include our own script files in the Resources / Themes / Any / directories if this directory is not used. We use the names of the script files we will include as parameters. There is no need to write extensions. It is possible to load more than one file at the same time.

Note: For version 5.5 and later , the Themes / directory will be used instead of Scripts / directory . Scripts / will not be included in new versions. Scripts / directory usage will continue, however, to avoid backward compatibility issues .

Parameters

Mixed $ Args ... The path to the js file to be called from the Resources / Themes / directory .
return Mixed

Use of

Import::script('Validation');

If you want to include more than one script file at the same time, we use it in the following way.

Import::script('Upload', 'Validation', 'Form');
Variable Transferability

If you want to import the imported script file as a variable data, the last parameter should be entered as true .

$script = Import::script('Upload', 'Validation', 'Form', true);

Or;

$script = Import::usable()->script('Upload', 'Validation', 'Form');
Remote Linked Links

The link keys in the Settings / CDNLinks.php configuration file can be used to load the relevant script.

Import::script('jquery', 'jqueryUi', 'vue', 'react', 'angular');

 

 

# Something ( ZN >= 0.0.1 )


It is used to include .php, .css or .js files.

Parameters

String $ Page The path of the file to be called from any directory.
Array $ data = NULL The display sequence to be sent.
Bool $ usable = false Can you transfer the content of the view?
return Mixed

Use of

Import::something(STYLES_DIR . 'site.css');
Import::something(CONTROLLERS_DIR . 'contact.php');
Import::something(CONTROLLERS_DIR . 'contact.php', ['data1' => 1, 'data2' => 2]);
Variable Transferability
$page = Import::something(CONTROLLERS_DIR, NULL, true);

This usage is in the css and js installs.

 

 

# Recursive ( ZN >= 3.0.0 )


Used to determine whether to perform an internal directory scan.

Parameters

Bool $ recursive = true Is there a directory index scan?
return this

Use of

Import::recursive()->plugin('Bootstrap');
Import::recursive()->theme('BluePrint');

 

 

# Theme ( ZN >= 3.0.0 )


By specifying the name of the theme directory in the following directories, it is possible to automatically load every file related to the theme in the directory.

Project: Resources / Themes /
Partner: External / Resources / Themes /

Parameters

Mixed $ Theme Theme name.
Bool $ recurseive = false Is there a directory index scan?
Bool $ usable = false Can you transfer the content of the view?
return Mixed

Use of

Import::theme('MyTheme');
Sub Index Scan

Used to load files in all subdirectories within the specified directory. In other words, it also scans the subdirectories. The second parameter must be set to true or the recursive () method should be used.

Import::theme('Slider', true);
Variable Transferability

If desired to be used is transferred to a variable 3 parameter to true must be set or usable () should be utilized in the method.

Import::theme('Slider', false, true);
Selective Upload

To be able to include more than one file or directory, parameter 1 is specified in the array data type.

Import::theme(['BlueTheme', 'RedTheme', 'BlackTheme/black.css', 'style.css']);

Package available for use usable()and recursive()use of the method is effective in this method.

 

 

# Plugin ( ZN> = 3.0.0 )


By specifying the name of the plugin directory in the following directories, it is possible to automatically load every file related to the plugin in the directory.

Project: Resources / Plugins /
Partner: External / Resources / Plugins /

Parameters

Mixed $ Plugin The name of the plugin.
Bool $ recurseive = false Is there a directory index scan?
Bool $ usable = false Can you transfer the content of the view?
return Mixed

Use of

Import::plugin('MyPlugin');
Sub Index Scan

Used to load files in all subdirectories within the specified directory. In other words, it also scans the subdirectories. The second parameter must be set to true or the recursive () method should be used.

Import::plugin('Slider', true);
Variable Transferability

If desired to be used is transferred to a variable 3 parameter to true must be set or usable () should be utilized in the method.

Import::plugin('Slider', false, true);
Selective Upload

To enable inclusion in more than one file or directory, parameter 1 is specified in the array data type.

Import::plugin(['MyPlugins', 'bootstrap/bootstrap.css', 'bootstrap/boostrap.js']);

In the above example, the following files are installed.

Themes / myplugins / loads all the files of the directory css and js with Themes / boostrap / boostrap.css and Themes / boostrap / boostrap.js.

 

 

# Handload ( ZN >= 3.0.0 )


It is used to include function-containing files in the following directories. There is no need to specify an extension. It is especially useful for making function definitions necessary for progeny.

Project: Starting / Handload /
Common: External / Starting / Handload /

Parameters

Mixed $ Args ... File name.
return Mixed

Use of

Import::handload('funcFile1', 'funcFile2');

 

 

# MasterPage ( ZN >= 1.0.0 )


The masterpage is used to ensure that all internal pages in your project can be used on a common page. Masterpage use is  described in detail in this section .

Parameters

Array $ data Used to send data to the masterpage's bodyPage set page.
Array $ header Used to set the master page's top page information.
return String
Masterpage Configuration

Masterpage related settings are in the following file. 

File: Config / Masterpage.php