admidio icon indicating copy to clipboard operation
admidio copied to clipboard

Understandment Questions to Smarty integration

Open Galileon-venta opened this issue 1 year ago • 15 comments

Admidio utilizes Smarty but only for parts of the Views... thereby theme customization provides only restricted possibilies to change the display of the different Module views.

Why is the design like that?

Question also applies for the language files... shouldnt it be possible to tweak them via a theme and not by changing the "core" Code?

Galileon-venta avatar Sep 09 '22 19:09 Galileon-venta

That is because of the history of Admidio. First we don't had any theme customizition. Later we added it and implement it, were it was easy. If I would start new with Admidio I would implement a better more integrated way of Smarty.

But if there is time or someone who want's to push the integration of Smarty, it would be very nice.

Fasse avatar Sep 10 '22 11:09 Fasse

I did not do PHP for a longer time now and yet I have problems to find my way thru the Sourcecode but ill keep this in Mind and may encouple parts into the theme.

Galileon-venta avatar Sep 10 '22 12:09 Galileon-venta

Please start with small parts so we can have a view how this could be best implemented. Later we can than add more parts.

Fasse avatar Sep 11 '22 10:09 Fasse

Hey all, I have started to do this as well. My idea is to extend the "HtmlElement extends \Smarty" and add a Render Method in it:

public function render($templateName, $asigns) {
        global $gL10n;
        foreach($asigns as $key => $asign) {
            $this->assign($key, $asign);
        }

        $this->assign("ADMIDIO_URL", ADMIDIO_URL);
        $this->assign("FOLDER_LIBS_SERVER", FOLDER_LIBS_SERVER);
        $this->assign("data", $asigns);
       
        $this->assign('l10n', $gL10n);
        return $this->fetch("sys-template-parts/".$templateName.'.tpl');
    }

I have started with a HTMLForm part for testing which would look like this:

public function addInput($id, $label, $value, array $options = array())
    {
...
  $optionsAll["attributes"] = $attributes;
        $this->addHtml($this->render("form.input", $optionsAll));
    }

So at the end we are just calling all the "add*" Methods as they are for now, but we will render all that stuff in a Smarty template.

What do you think about that idea? I have committed this to my fork: https://github.com/marchorst/admidio/commit/989b5f228f01c80edadb85e9ed51f3dfdc5949d4

marchorst avatar Sep 11 '22 14:09 marchorst

For me that looks like an implementation of my basic theoretical idea to aproach this; it does not change that much of the logic while uncoupling the template parts

Galileon-venta avatar Sep 11 '22 15:09 Galileon-venta

Would be great if you could also check which parts I have missed so far @Galileon-venta Thanks, Marc

marchorst avatar Oct 03 '22 14:10 marchorst