Download the PHP package aaronkirkham/wp-timber-view-controller without Composer

On this page you can find all versions of the php package aaronkirkham/wp-timber-view-controller. 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 wp-timber-view-controller

WordPress Timber View Controller

If you're like me and hate writing 2 files to render a twig template for WordPress (e.g. page.php for context and page.twig for markup) then this library is for you. It follows the WordPress Template Hierarchy so you can also create files such as single-{post_type}.twig.

How to use

Using wp-timber-view-controller is easy.

composer require aaronkirkham/wp-timber-view-controller

Then place the following code inside your themes functions.php:

and that's it. Your Twig templates will be automatically rendered.

This library uses the internal Timber::$dirname variable to locate your templates (default folder is views). If you want your files to live in a different folder, you must overwrite this.

If you need to add variables to the Timber context, there are handy filters available for that.

Filter: timber_context--%TEMPLATE%

The timber_context--%TEMPLATE% filter (where %TEMPLATE% is the current template name) is fired when the specific template is rendered. This is handy if you want to get posts from WordPress on specific pages.

In the above examples, the message variable will be available on all pages which are rendered using the 404.twig template, and the post variable will be available on all single.twig templates.

FYI

If you want to add data into the context for every template, you should use the timber_context filter which is fired by Timber.

The variable foo is now available on all templates.

White screen?

If your twig templates are not rendered or you just have a white screen, you should turn on WP_DEBUG inside wp-config.php to view a hierarchical list of templates that wp-timber-view-controller tried to render. Double check the displayed template path and file names are correct.


All versions of wp-timber-view-controller with dependencies

PHP Build Version
Package Version
Requires timber/timber Version ^1.7
brain/hierarchy Version ^2.3
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 aaronkirkham/wp-timber-view-controller contains the following files

Loading the files please wait ....