Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Multi-language images using translation entities

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 06-23-2021, 12:24 PM
  The Knotty Celt's Avatar 
The Knotty Celt The Knotty Celt is offline
 

Member
  
Join Date: Jan 2020
Posts: 25
 

Default Multi-language images using translation entities

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. (MlBanner.txt).


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.
__________________
X-Cart version 5.4.1.31
PHP version 7.3.29
Reply With Quote
  #2  
Old 06-28-2021, 11:12 AM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 407
 

Default Re: Multi-language images using translation entities

Is it even possible to use items list to save module's setting to begin with?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #3  
Old 06-28-2021, 11:22 PM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 407
 

Default 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?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #4  
Old 08-02-2021, 01:26 PM
  The Knotty Celt's Avatar 
The Knotty Celt The Knotty Celt is offline
 

Member
  
Join Date: Jan 2020
Posts: 25
 

Default 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.
__________________
X-Cart version 5.4.1.31
PHP version 7.3.29
Reply With Quote
  #5  
Old 09-26-2021, 07:57 AM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 407
 

Default 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>?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:30 PM.

   

 
X-Cart forums © 2001-2020