piotr-cz / Twig-extensions-Joomla

Joomla-Framwork functionality in Twig templates
MIT License
5 stars 1 forks source link

Using twig extension in jooma cms #3

Open vladotesanovic opened 9 years ago

vladotesanovic commented 9 years ago

Thanks for building this extension.

My problem was to implement this in current Joomla installation ( 3.3 ).

What I did ( just to get it work ): \joomla\language\src\Language.php

in __construct() functio Before everything.

$this->lang = \JFactory::getLanguage()->getTag();

in loadLanguage() function

/*
if (file_exists($filename))
{
    $strings = $this->parse($filename);
}
*/

$strings = array();

        foreach(\JFactory::getLanguage()->getPaths() AS $key => $languages)
        {
            foreach (array_keys($languages) as $lng) {

                if(file_exists($lng))
                {
                    $strings = array_merge($this->parse($lng), $strings);
                }

            }
        }
piotr-cz commented 9 years ago

Hi there, This is an extension for Twig that lets you use Joomla Frameworks' Language package (Text class to be specific, this package is very similar to CMS JLanguage and JText). So, it's not for Joomla CMS, but for Joomla Framework (see http://framework.joomla.org/ and https://github.com/joomla/joomla-framework/). Maybe the repository name is kinda misleading.

While the plan is to rewrite the CMS around version 4 to be based on the Framework, this seems to be complex task and there are few conceptual issues being discussed (https://github.com/joomla-cms/start-here).

As for the CMS templates in Twig, Twig renderer would need to be implemented in the template itself. When I look at the _JDocumentHTML::loadTemplate, there are no hooks, just output buffering. Twig Renderer would need to be called in each file that's being required by the core (like HTML overrides).

vladotesanovic commented 9 years ago

yes, I understand.

What I did: I created new View class that extend JViewLegacy, but in display method it implement your Twig exension.

Instead of extending JViewLegacy i extend MyTwigView and in view component/view/myview/twig/ i store all twig templates.

No problem so far.

piotr-cz commented 9 years ago

What's the problem then?

vladotesanovic commented 9 years ago

There is no problem,