Jump to content

Templates, namespace and modules problem


Juergen
 Share

Recommended Posts

Hello @ all,

I have upgraded all my templates to use the namespace attribut introduced in PW 3.

Therefore I have added "namespace Processwire" at the top of each template. In the backend I have disabled the loading of the compiler for each template.

I works well, but I have problems loading modules in the templates.

In my case I use AIOM to combine multiple files into one, but the syntax from the AIOM docs doesnt work anymore. The URL to the merged file cannot be created.

I thougt that disabling compiler only for templates doesnt affect modules.

Has anyone an idea to get it working again?

Best regards Jürgen

Link to comment
Share on other sites

If you've added "namespace ProcessWire" to the top of your template files, then you template files are now running in the ProcessWire namespace rather than the global one. AIOM runs in the global namespace, since it's not specifically made for PW3. Since AIOM uses static method calls to add files (if I recall correctly), you would just need to change those calls from "AIOM::something" to "\AIOM::something", with the leading backslash. That tells PHP to access something from the global namespace.

By the way, you don't have to disable compilation for templates individually if you don't want to. If you don't want the template compiler at all, just set $config->templateCompile = false; in your /site/config.php and the template compiler will be completely turned off. 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...