X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Multi-language images using translation entities (https://forum.x-cart.com/showthread.php?t=78265)

The Knotty Celt 06-23-2021 12:24 PM

Multi-language images using translation entities
 
1 Attachment(s)
PREMISE

I am working on a multi-language banner slider module. I have already tested the java scripts, CSS and HTML required for the banner slider to work. Rather than having to edit the body field of a page's translation entity each time I want to add a new slide, or remove a slide, I would much rather have things setup in a similar fashion to the built-in Banner Rotation settings.


STRUCTURE
Code:

XLite/Module/<dev>/<mod>
├── install.yaml
├── main.yaml
├── Controller
│ └── Admin
│    └── MlBanner.php
├── Model
│  ├── Image
│  │  └── MlBannerImage.php
│  ├── MlBanner.php
│  ├── MlBannerTranslation.php
│  └── Repo
│      ├── Image
│      │  └── MlBannerImage.php
│      └── MlBanner.php
└── View
    ├── Form
    │  └── MlBanner.php
    ├── ItemsList
    │  ├── MlBannerImages.php
    │  └── Model
    │      └── MlBanner.php
    ├── MlBanner.php
    ├── Model
    │  └── MlBanner.php
    └── Tabs
        └── FrontPage.php



Since I am not able to paste all PHP code here, I have included them in a concatenated text file with file headings. (Attachment 5653).


ISSUE AT HAND
When skins/admin/modules/<dev>/<mod>/body.twig is as follows:
Code:

{{ widget('XLite\\Module\\<dev>\\<mod>\\View\\Model\\MlBanner') }}
The settings for the module do show up under the appropriate Front Page tab, and I able to change and save the settings here. However, if my body.twig contains, instead:
Code:

{{ widget('XLite\\Module\\<dev>\\<mod>\\View\\ItemsList\\Model\\MlBanner') }}
the "Add Banner" button defined appears and when I click it, it does bring up a new record, however, there is no "submit" button, so I am unable to store the new records.
If I include both widgets in the body.twig, I do get the settings and the submit button, but the submit button only affects changes made to the settings portion and not the records being added.


I have looked at some classes which yield results similar to those I desire, but when I apply those adaptations, nothing seems to bring up both the settings and record entry table with the same submit button to apply changes to either. The Banner Rotation template for example, only calls a single widget:
Code:

{{ widget('XLite\\View\\Model\\BannerRotation') }}


I simply am not able to ascertain the cause of the behaviour and how to achieve the expected behaviour.

Ed B. 06-28-2021 11:12 AM

Re: Multi-language images using translation entities
 
Is it even possible to use items list to save module's setting to begin with?

Ed B. 06-28-2021 11:22 PM

Re: Multi-language images using translation entities
 
Quote:

Originally Posted by Ed B.
Is it even possible to use items list to save module's setting to begin with?



In other words, if you want to use items list, maybe you should create a separate tab/page, one with module settings (whatsoever you have there_ and one with the items list. And for the itemslist tab/page, your controller should extend \XLite\Controller\Admin\AAdmin instead of \XLite\Controller\Admin\Settings maybe?

The Knotty Celt 08-02-2021 01:26 PM

Re: Multi-language images using translation entities
 
When I remove the settings from the tab outright, and have only the ItemsList, The "submit" button still fails to display when attempting to add a new record.

Ed B. 09-26-2021 07:57 AM

Re: Multi-language images using translation entities
 
My experiences tend to suggest that when the submit button doesn't show up even when you put the code for it (well, sometimes one can simply forget...) it is usually because there is a problem with the entity definition or setter definition. Since you have an entity that is in one to one correspondence with another entity, sometimes defining setter can get tricky.


Otherwise, in your attached code, I see
Code:

namespace XLite\Module\<dev>\<dev>\Controller\Admin;
in the class Controller/Admin/MlBanner.php (where it should be <dev>/<mod>, but I would presume the error was made while you replaced real developer name and module name with <dev> and <mod>?


All times are GMT -8. The time now is 12:26 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.