5.5 - Put all templates (block templates, single pages) in one directory

Permalink
Hi There,

Is there a simple way to have your single pages (login, profile, cart, checkout etc) and block templates in the one directory?

This would simplify the installation of our base-theme a lot.

We've tried placing templates and directories into the theme folder and using site_theme_paths.php but this seems to render c5's default layout into view.php.

But a lot of our single pages use more sophisticated layouts (and the core_commerce ones have a lot of other associated files) - which means they only work in the single pages directory.

Hopefully that makes sense - any help would be much appreciated.

Cheers

Ben

 
xaritas replied on at Permalink Reply
It sounds like what you are describing is exactly what the 'packages' mechanism is for. It lets you bundle single pages, page types, controllers, themes, libraries, helpers, elements, tools, models and probably stuff I forgot into a single directory, which you can ship as a zip file (or whatever).

http://www.concrete5.org/documentation/developers/system/packages/...
cmscss replied on at Permalink Reply
Thanks for that - any tips for putting together a package if you're a designer?

Will give it a go anyway!
xaritas replied on at Permalink Best Answer Reply
You need to be able to do a little bit of PHP to take advantage of this.

When you put files into the override directories (SITE_ROOT/themes, SITE_ROOT/single_pages, etc.) Concrete5 just finds them magically. However concrete will not look into package directories unless explicitly directed.

The way things are loaded is not uniform. There are basically two ways:

1) For things that have a Loader, like elements, or libraries or models, you need to modify your code to pass in a reference to which package to look into. See this for a complete example:http://www.concrete5.org/api/Core/Loader.html...

Example:
<?php Loader::element('my_awesome_packaged_up_element'); // FAIL ?> 
<?php Loader::packageElement('my_awesome_packaged_up_element', 'awesome_pack'); // Cool element, bro ?>



2) Other things that are directly invoked by the core, like single pages, page types, and blocks, have to be explicitly installed by the package during the install() routine. For example, you might use:

public function install() {
  $pkg = parent::install();
  BlockType::installBlockTypeFromPackage('hello_world', $pkg); 
  PageTheme::add('theme_booya', $pkg);
  CollectionType::add($data, $pkg);};
}


In general, if C5 can't find your thing, it's because you didn't install it, or you are loading it from Core and not from your package.
cmscss replied on at Permalink Reply
Awesome - thank you so much for the info!

Will give this a go later today.

Cheers

Ben