Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understandment Questions to Smarty integration #1304

Closed
Galileon-venta opened this issue Sep 9, 2022 · 16 comments
Closed

Understandment Questions to Smarty integration #1304

Galileon-venta opened this issue Sep 9, 2022 · 16 comments

Comments

@Galileon-venta
Copy link

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?

@Fasse
Copy link
Member

Fasse commented Sep 10, 2022

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.

@Galileon-venta
Copy link
Author

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.

@Fasse
Copy link
Member

Fasse commented Sep 11, 2022

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

@marchorst
Copy link
Contributor

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:
marchorst@989b5f2

@Galileon-venta
Copy link
Author

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

@marchorst
Copy link
Contributor

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

@Fasse
Copy link
Member

Fasse commented Jan 2, 2023

@marchorst Thank you very much for the implementation of the form templates. I have done some further fixes to the implementation.

Do you plan further smarty integration? Maybe we should try that the HtmlForm class will be directly from the Smarty class. Now its from the deprecated HtmlFormBasis class, which we want to eleminate.

@marchorst
Copy link
Contributor

I can definitely take a look on this and start further development, but I will not have the time in the next one or two month

@Fasse Fasse changed the title Understandment Questions Understandment Questions to Smarty integration Mar 14, 2023
@Fasse
Copy link
Member

Fasse commented Mar 14, 2023

Another step was done. #1378
Within Admidio 4.3 you can customize the menus even better with Smarty templates.

@marchorst
Copy link
Contributor

@marchorst Thank you very much for the implementation of the form templates. I have done some further fixes to the implementation.

Do you plan further smarty integration? Maybe we should try that the HtmlForm class will be directly from the Smarty class. Now its from the deprecated HtmlFormBasis class, which we want to eleminate.

I think HtmlForm extends HtmlFormBasic, which is in fact not not used by any other core component as far as I can see this.
I would suggest that I migrate these to classes. We would then end up with HtmlForm which extends HtmlElement (And this is extending smarty) + mark the HtmlElementBasic as deprecated (I am pretty sure there are some Plugins which use this class)
Any other thoughts on this?

@Fasse
Copy link
Member

Fasse commented Mar 19, 2023

Why not ignore HtmlElement and extend Smarty to HtmlForm.

The structure of HtmlElemnt, HtmlTable, HtmlList ... is old and I want not generate the Html structure in PHP. Therefore we have now Smarty. So we should directly genereate Smarty templates out of the HtmlForm class. Maybe we can remove the other classes in future if there are more things migrated to Smarty templates.

@Fasse Fasse added the theme label Mar 19, 2023
@marchorst
Copy link
Contributor

Understand! Yes makes sense - I will take a deeper look on this.

@Fasse
Copy link
Member

Fasse commented May 23, 2023

@marchorst What do you think, is it better to separate the menu parts in separate files and include that files within the index.tpl or should it still be part of the index.tpl ?

@marchorst
Copy link
Contributor

Makes definitly sense to split up the UI components a bit :)

@Fasse
Copy link
Member

Fasse commented Aug 26, 2023

I implemented the last missing form objects (select and static) and removed the HtmlFormBasic class.

@Fasse
Copy link
Member

Fasse commented Jun 15, 2024

I will close this issue because the question was answered and main parts are now customizable via Smarty.

@Fasse Fasse closed this as completed Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants