Инструменты пользователя

Инструменты сайта


limb2:en:file_path_resolving

File path resolving

From the very beginning Limb has been developed in mind to manage several projects being a shared instance. Sometimes projects require a bit different behavior then default one. That's why Limb uses special file path resolving technique.

First file is searched in the project file structure then in the Limb file structure.

This technique makes use of the two constants you defined in the setup.php(or setup.override.php) PROJECT_DIR and LIMB_DIR.

That's why the file structures of the Limb based project and Limb are similar.

This PROJECT_DIR → LIMB_DIR resolving technique is applied almost to everything:

  • all object factories like db_table_factory, action_factory, site_object_factory, etc.</li>
  • *.ini files - localized strings, configuration files etc.</li>
  • WACT templates, so it's easy to override default Limb template in the project</li>

Sometimes it's not just a file path resolving technique it's rather a class resolving technique(it depends on the resolver). For example, path to the action might look like this /article/edit_article_actions. In this case the action_factory would interpret it as follows:

  • append '.class.php' to the path
  • search in PROJECT_DIR/core/actions/
  • search in LIMB_DIR/core/actions/

In fact, if you need some different functionality in the specific project you can copy the Limb file to your project and modify it. It's a convenient way to extend and override default functionality.

From the pure OOP point of view it's quite a dirty hack - we admit that, that's why we are working on the packages technique, so this feature will be available for WACT templates only.

Template file path resolving works a little different. It tries to take into account localization during template compilation.

It searches in the following directories(order is important, the first match is returned):

  • PROJECT_DIR . '/design/main/templates/_' . CONTENT_LOCALE_ID . '/' . $file_path</li>
  • PROJECT_DIR . '/design/main/templates/' . $file_path</li>
  • LIMB_DIR . '/design/main/templates/_' . CONTENT_LOCALE_ID . '/' . $file_path</li>
  • LIMB_DIR . '/design/main/templates/' . $file_path</li>

That’s why if you want to customize template according to current locale in the runtime you should use something like this:

<locale:LOCALE name='en'>
  <core:INCLUDE file='_en/type_tables.html'>
</locale:LOCALE>
<locale:LOCALE name='ru'>
  <core:INCLUDE file='/_ru/type_tables.html'>
</locale:LOCALE>

It's a good practice to use <locale:string> tag to output localized strings in templates </locale:string>.

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
  _____   ____  ____   ____   ____
 / ___/  / __/ /_  /  / __/  /  _/
/ /__   / _/    / /_ / _/   _/ /  
\___/  /_/     /___//___/  /___/
 
limb2/en/file_path_resolving.txt · Последние изменения: 2010/11/10 10:02 (внешнее изменение)