juek / CustomSections

Developer plugin for rapid prototyping of custom section types in Typesetter CMS
GNU General Public License v2.0
3 stars 7 forks source link

i18n #40

Closed mahotilo closed 6 years ago

mahotilo commented 6 years ago

When I try to "Recreate Custom sections" on any page with custom section type, that used var i18n, I get this error message. As example, I created the page with single "multi_lang_demo" section.

> Oops, an error occurred while generating this page.
> 
> Error Details
> 
> array(
>    [type] => (integer)1
>    [message] => (string)Uncaught Error: Access to undeclared static property: CustomSections_Admin::$i18n in D:\Internet\www\root\TS\addons\CustomSections-master\_types\multi_lang_demo\section.php:18
> Stack trace:
> #0 D:\Internet\www\root\TS\addons\CustomSections-master\CustomSections_Admin.php(149): include()
> #1 D:\Internet\www\root\TS\addons\CustomSections-master\CustomSections_Admin.php(33): CustomSections_Admin->Recreate_custom_sections()
> #2 D:\Internet\www\root\TS\addons\CustomSections-master\CustomSections_Admin.php(17): CustomSections_Admin->CommandHandle()
> #3 D:\Internet\www\root\TS\include\tool\Output.php(648): CustomSections_Admin->__construct(Array)
> #4 D:\Internet\www\root\TS\include\tool\Output.php(623): gp\tool\Output::ExecClass(true, 'CustomSections_...', Array, Array)
> #5 D:\Internet\www\root\TS\include\tool\Output.php(577): gp\tool\Output::_ExecInfo(Array, Array)
> #6 D:\Internet\www\root\TS\include\admin\Page.php(232): gp\tool\Output::ExecInfo(Array, Array)
> #7 D:\Internet\www\root\TS\include\admin\Page.php(39): gp\admin\
>    [file] => (string)D:\Internet\www\root\TS\addons\CustomSections-master\_types\multi_lang_demo\section.php
>    [line] => (integer)18
> )
> Reload this page
> 
> Note: Error details are only displayed for logged in administrators
juek commented 6 years ago

This will fix it. But beware: Recreating sections on a Multi-Language Manager site will always use the admin UI language, because we do not have a MLM/language context on Custom Sections' Admin page.

mahotilo commented 6 years ago

Thx! It works. Juergen, can I ask you for one more consultation?

I try to call php function via ajax from js script in my custom section type. I can do it, but php file (where function declared ) executes out of TS context. So I can not call any TS var and functions. I have read yours posts with a2exfr on this theme, but it helps me not:) To be precise, I try to call $gp_mailer->SendEmail from js event on modal wizard button. I try to sent shopping cart content via email. Can you give me a direction to looking for an answer?

thomasfrobieter commented 6 years ago

Sounds familar to me, we've done something similar here: https://github.com/webksde/Typesetter-Custom-Sections--Contact-Form (take a look at the modification to the Addon.ini described there)

mahotilo commented 6 years ago

Thanks. I also try to hack addon.ini but via Gadget: and unsuccessfully. I go to study your code.

juek commented 6 years ago

Thanks Thomas.

Yes, currently this is a known weakness.

But I'll try to provide a simpler hook via PageRunScript without the need to change Addon.ini. Gimme a few minutes.

juek commented 6 years ago

Sorry for the delay. See this commit.

Hope i'ts clear.

mahotilo commented 6 years ago

Thank you a lot. I feel, it's exactly what I try to do for 3 days.

Hope i'ts clear.

Not for dummies:) Is script.php a mandatory name? If yes, it's no problem. I simply want to understand correctly.

juek commented 6 years ago

Is script.php a mandatory name?

It is. But you can always include others from there.

juek commented 6 years ago

In the latest commit, I added a sample how to save data (a log in this case).

mahotilo commented 6 years ago

Thx.