Download the PHP package arif-rh/ci4-themes without Composer

On this page you can find all versions of the php package arif-rh/ci4-themes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ci4-themes

CodeIgniter 4 Themes

Build Status Coverage Status Quality Gate Status Vulnerabilities Security Rating Bugs Maintainability Rating

Installation

  1. install via composer, run composer require arif-rh/ci4-themes

  2. setup your theme config (optional), if you don not setup config, then it will use default one

  3. if you do not change config, theme folder structure will be like below, so copy all your files here:

CI4 Themes Documentation

Table of Contents

Themes Config

This is default config themes. You can override themes by extending this default themes, for example make file inside App\Config\

You can use this new theme config later.

Themes

Class Themes

init

Instantiate Themes with theme config, if you don't pass $config then it will use default one.

This method is static.

Parameters:

Parameter Type Description
$config \Config\Themes Theme Configuration

Example Usage:


addCSS

Add CSS file(s) to be loaded inside template. This must be used after Themes::init(). All non-static method must be called after Themes::init().

Parameters:

Parameter Type Description
$css_files string|array CSS filename that will be loaded in template. This CSS file must be exist inside css_path in \Config\Themes

Return Value:

Arifrh\Themes\Themes

NOTE: All non-static method always return the chained object, so you can call next method directly.

Example Usage:

There are 3 ways you can add CSS files:


addJS

Add js file(s) to be loaded inside template. This method has same usage with addCSS() method. The different just parameter(s) to be passed are JavaScript filename.

Parameters:

Parameter Type Description
$js_files string|array JS filename that will be loaded in template. This JS file must be exist inside js_path in \Config\Themes

Example Usage:


addInlineJS

Inject inline JavaScript code to the template.

Parameters:

Parameter Type Description
$js_scripts string Valid JavaScript code to be added.

addExternalCSS

Add CSS from external source (fully CSS URL). This is used when we need to include CSS files outside css_path in theme folder.

Parameters:

Parameter Type Description
$full_css_path string|array CSS filename with full path.

addExternalJS

Add JS from external source (fully JavaScript URL). This is used when we need to include JavaScript files outside js_path in theme folder.

Parameters:

Parameter Type Description
$full_js_path string|array JavaScript filename with full path.

loadPlugins

Plugins are JavaScript Libraries that will be mostly used in many place the project, but not all page always use it. For example, DataTable, Bootbox, Select2.

Parameters:

Parameter Type Description
$plugins string|array Registered plugins key name.

Plugins are registered inside \Config\Themes. This is an example in \Arifrh\Themes\Config\Themes about how to define plugins.

Example Usage:


useFullTemplate

Parameters:

Parameter Type Description
$use_full_template boolean

This Themes by default will use 3 kind of templates. All of these templates are located inside themes folder.

  1. Header Header is a template that usually used to display header of site, contains <html>,<title>, <head> and opening <body> html tags. This header section usually is same for all pages, and being used to load common CSS files.

    By default, header template will use header.php filename, you can change this from \Config\Themes.

  2. Template This is main template. Content will be injected here.

    By default, template use index.php and this also can be changed from \Config\Themes.

  3. Footer Footer is a template that usually used to display footer of site, contains closing tags for <body> and <html>. This footer section usually is same for all pages, and being used to load common JavaScript files.

    By default, footer template will use footer.php filename, you can change this from \Config\Themes.

In a few case, you may need to display custom template, for example your default template has navbar, sidebar, content and main footer. But in login page, you need to display page without navbar, sidebar and has different footer. In this case, you can use full template.

  1. make your login view with full html and body tags
  2. before rendering template, call useFullTemplate

setHeader

Header that being set in \Config\Themes will be used as default theme header.

Parameters:

Parameter Type Description
$header_name string Header file name

In a few case, one or two page may need to use different header, then you can set it on-the-fly.


setTemplate

Template that being set in \Config\Themes will be used as default theme main template.

Parameters:

Parameter Type Description
$template_name string Template file name

In a few case, one or two page may need to use different template, then you can set it on-the-fly.


setFooter

Footer that being set in \Config\Themes will be used as default theme footer.

Parameters:

Parameter Type Description
$footer_name string Footer file name

In a few case, one or two page may need to use different footer, then you can set it on-the-fly.


setTheme

Themes that being set in \Config\Themes will be used as default theme.

Parameters:

Parameter Type Description
$theme_name string Theme name

In a few case, one or two page may need to use different theme, then you can set it on-the-fly.

Note:


render

This is main method that will render any content using active theme templates.

Parameters:

Parameter Type Description
$viewPath string View file name, or string to be rendered directly into template
$data array Dynamic variable that will be passed into view

Basically, when you want to display view in CodeIgniter4, you are using view method. Now, just replace your view method with Themes::render() and view will be rendered based on your active theme.


renderCSS

This method will render all CSS themes. This usually should be called inside header template


renderJS

This method will render all JavaScript themes. This usually should be called inside footer template.


setPageTitle

Parameters:

Parameter Type Description
$page_title string Text will be used as title page

Set Page Title - used in <title> tags. If you do not set page title, then theme will use Controller | Method name as default title. $page_title variable always be available for themes, It can be used inside <title> tag.


setVar

Set Variable to be passed into template. Actually this can be passed using $data parameter in Themes::render() method. So this is just an alias to passing data into template.

Parameters:

Parameter Type Description
$key string|array if string, this is key of dynamic variable. If using array, then array index will be used as dynamic variable inside template
$value mixed

Example Usage:


getData()

Get All Themes Variables


All versions of ci4-themes with dependencies

PHP Build Version
Package Version
Requires codeigniter4/settings Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package arif-rh/ci4-themes contains the following files

Loading the files please wait ....