Download the PHP package thelia/twig-module without Composer

On this page you can find all versions of the php package thelia/twig-module. 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 twig-module

Twig integration for Thelia

This module use Twig template engine as parser for Thelia and replace Smarty.

This module is not stable and is still in development. See the RoadMap if you want to know which features are missing

Summary :

Installation

You can only install this module with composer :

Activation

It is required to enable this module with the cli tools and then disable TheliaSmarty module :

Usage

Template files must be suffixed by , for example

The template structure is the same as the actual structure, so you can referer to the actual documentation

You can test the module with this module : https://github.com/bibich/TheliaTwigTest

Syntax

Loop

loop feature is a Twig tag, you have to use it like a block. All loop's parameters use literals syntax and are the same as the acutal parameters. The tag start with and finish with

example :

Conditional loop

Conditional loops are implemented. As for Smarty a can wrap a and can be used after the related loop. must be used after the related

Paginated loop

Paginated loop works exactly like paginated loop for Smarty, just the syntax change. See the official documentation for all parameters : http://doc.thelia.net/en/documentation/loop/index.html#page-loop

Syntax example :

Url management

url

url is a function. It generates an absolute url for a given path or file.

parameters :

Parameters Description example
path The value of the path parameter is the route path you want to get as an URL
file The value of the file parameter is the absolute path (from /web) of a real file, that will be served by your web server, and not processed by Thelia
parameters paremeters added to the query string
current generate absolute URL grom the current URL
noAmp escape all as that may be present in the generated URL.
target Add an anchor to the URL

Complete example :

generated link : http://domain.tld?id=2&arg1=val1

url_token

same as function. This function just add a token paremeter in the url to prevent CSRF security issue.

example :

generated link : http://domain.tld?id=2&arg1=val1&_token=UniqueToken

current_url

return the current url

example :

previous_url

return the previous url saved in session

example :

index_url

return the homepage url

example :

Translation

default_domain

default_domain is a tag for defining the default translation domain. If defined you don't need to specify it when you want to translation a string in the current template.

Usage :

default_locale

tag for defining a locale and don't use the locale stored in session.

Usage :

intl

function for string translation

parameters :

Parameters Description Example
id the string to translate
parameters variable use if a placeholder is used in the string to translate => secure payment atos
domain message domain, will override domain defined with tag
locale specific locale to use for this translation. Will override locale defined with tag and the locale defined in session

Complete example :

Security

auth

tag checking if a user has access granted.

example :

Parameters :

Parameters Description
role In Thelia 2, a user can only have one of these two roles: ADMIN and/or CUSTOMER
resource if a user can access to a specific resource. See : http://doc.thelia.net/en/documentation/templates/security.html#resource
module Name of the module(s) which the user must have access
access access mode : CREATE, VIEW, UPDATE, DELETE
login_tpl This argument is the name of the view name (the login page is "login"). If the user is not granted and this argument is defined, it redirects to this view.

check_cart_not_empty

This tag checks if the customer's cart is empty, and redirects to the route "cart.view" if it is.

check_valid_delivery

Check if the delivery module and address are valid, redirects to the route "order.delivery" if not.

data access functions

All data access function allow to access to a specific property of an entity. For some of them through an id present in the query string, for others through data saved in session

admin

Provides access to the current logged administrator attributes using the accessors.

brand

Provides access to an attribute of the current brand (brand_id parameter in the query string). If the product_id is in the query string, the brand function will find the brand linked to the product.

cart

list of implemented parameters :

example :

category

Provides access to an attribute of the current category (category_id parameter is the query string). If the product_id is in the query string, the default category linked to this product is used.

config

return the value of a wanted configuration key. Default as second parameter if the key does not exists.

content

Provides access to an attribute of the current content (content_id in the query string).

country

Provides access to an attribute for the default country

currency

Provides access to an attribute of the current currency (saved in session)

customer

Provides access to an attribute of the logged customer

folder

Provides access to an attribute of the current folder (folder_id in the query string). If the content_id parameter is in the query string, the default linked folder will be used.

lang

Provides access to an attribute of the current lang saved in session

order

Provides access to an attribute of the current order

list of implemented parameters :

example :

product

Provides access to an attribute of the current product (product_id parameter in query string)

Cart postage

retrieves the postage amount of the current cart if it exists.

Thelia uses the following rules to select the country :

Inside the block this variables are defined :

format functions

format_date

return date in expected format

available parameters :

format_number

return numbers in expected format

available parameters :

format_money

return money in expected format

available parameters :

flash messages

has_flash

Test if message exists for the given type.

available parameters :

flash

Get all messages or messages for the given type. After the call of the function flash messages are deleted.

available parameter :

Hooks

hook tags

The tag allows you to get the content related to a specific hook specified by its name.

available parameters :

hookblock and forhook tags

The tag allows you to get the content related to a specific hook specified by its name. The content is not injected directly, but has to be manipulated by a forhook tag.

available parameters :

The tag iterates on the results of a hookblock tag. You should set the rel attribute to establish the link. You can use the forhook multiple times.

ifhook and elsehook tags

These tags will test if hook or hookblock are empty or not.

How to add your own extension

The tag allows you to add your own twig extension.

example :

Roadmap


All versions of twig-module with dependencies

PHP Build Version
Package Version
Requires thelia/installer Version ~1.1
twig/twig Version ~1.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 thelia/twig-module contains the following files

Loading the files please wait ....