overwirting site template

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

overwirting site template

Post by khizar » 20 Jan 2021, 12:44

Hi,

i have integrated aimeos with laravel 8 and i have given a task to add extra field in site form.
Image

When i try to overwirte the site template there are two directories in with site form is present
1) ext\ai-admin-jqadm\admin\jqadm\templates\locale\site\item-standard.php
2) ext\ai-sites\admin\jqadm\templates\locale\site\items-site.php

my aimeos app is using 2nd directorie(items-site.php) to render the site view
please tell which file do i have to overwrite in my extension and also how because there is no folder available in my
own extension(created through link given on aimeos documentation) to overwrite items-site.php
my extension folder contains
1)admin(folder)
2)client(folder)
3)config(folder)
4)controller(folder)
5)lib(folder)
6).gitignore
7)composer.json
8)manifest.php
9)phing.xml

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: overwirting site template

Post by aimeos » 20 Jan 2021, 12:47

Name your template file item-sites.php and add "ai-sites" to the "depends" section of the manifest.php file in the root of your extension. Then, your file is used instead of that from the ai-sites extension.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: overwirting site template

Post by khizar » 20 Jan 2021, 12:54

aimeos wrote: 20 Jan 2021, 12:47 Name your template file item-sites.php and add "ai-sites" to the "depends" section of the manifest.php file in the root of your extension. Then, your file is used instead of that from the ai-sites extension.
Thank you.it worked perfectly.It would be great if you guys make some video tutorials on the customization of admin panel or
make some changes in documentation in order to make it easy for new developers because the documentation is very hard to
understand.Thanks again.

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: overwirting site template

Post by aimeos » 20 Jan 2021, 13:02

Help is always welcome! Create a PR and add a clarification to the page or section where information is missing here:
https://github.com/aimeos/aimeos-docs

Don't be afraid if your sentences are not perfect, we will check, fix and extend your PR before merging.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: overwirting site template

Post by khizar » 21 Jan 2021, 06:40

aimeos wrote: 20 Jan 2021, 13:02 Help is always welcome! Create a PR and add a clarification to the page or section where information is missing here:
https://github.com/aimeos/aimeos-docs

Don't be afraid if your sentences are not perfect, we will check, fix and extend your PR before merging.
Hi,
i have successfully added field in site form and also added a field in table by adding a file locale.php in the
directory ext\ai-moudhah\lib\custom\setup\default\schema. that file contains the following code

Code: Select all


return [
  'table' => [
    'mshop_locale_site' => function ( \Doctrine\DBAL\Schema\Schema $schema ) {

        $table = $schema->getTable( 'mshop_locale_site' );

        $table->addColumn(  'city', 'string', ['length' => 255] );
       

        return $schema;
    }
]
];
Now i want to store that field in table for that purpose i have made a decorator(following the doucmentation) in the
directory ext\ai-moudhah\lib\custom\src\MShop\Locale\Manager\Site\Decorator\Myproject.php that file contains the following code

Code: Select all

	
namespace Aimeos\MShop\Locale\Manager\Site\Decorator;
 
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
    private $attr = [
        'city' => [
            'code' => 'city',
            'internalcode' => 'city',
            'label' => 'My new column',
            'type' => 'string',
            'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
        ],
    ];
 
    public function getSaveAttributes()
    {
       
        return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
    }
 
    public function getSearchAttributes( $sub = true )
    {
        return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
    }
}
and also i have made changes in config/mshop.php file

Code: Select all

return [
    'site' => [
        'manager' => [
            'decorators' => [
                'local' => ['Myproject']
            ]
        ]
    ]
];
but the value is not storing in site table.please guide me what i am doing wrong
the field which i have added is

Code: Select all

<div class="form-group row mandatory">
								<label class="col-sm-4 form-control-label"><?= $enc->html( $this->translate( 'admin', 'City' ) ); ?></label>
								<div class="col-sm-8">
                                    <input class="form-control item-city" type="text" tabindex="1"
										name="<?= $this->formparam( array( 'item', 'locale.site.city' ) ); ?>"
										placeholder="<?= $enc->attr( $this->translate( 'admin', 'Internal name (required)' ) ); ?>"
										value="<?= $enc->attr( $this->get( 'itemData/locale.site.city' ) ); ?>" />
								</div>
							</div>

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: overwirting site template

Post by khizar » 21 Jan 2021, 07:37

aimeos wrote: 20 Jan 2021, 13:02 Help is always welcome! Create a PR and add a clarification to the page or section where information is missing here:
https://github.com/aimeos/aimeos-docs

Don't be afraid if your sentences are not perfect, we will check, fix and extend your PR before merging.
would you please reply me.i am waiting for reply

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: overwirting site template

Post by aimeos » 22 Jan 2021, 12:28

This seems to be wrong:

Code: Select all

return [
    'site' => [
        'manager' => [
            'decorators' => [
                'local' => ['Myproject']
            ]
        ]
    ]
];
It should be in ./config/mshop.php of your extension:

Code: Select all

return [
	'locale' => [
		'manager' => [
			'site' => [
				'decorators' => [
					'local' => ['Myproject']
				]
			]
		]
	]
];
PS: If you need immediate support, you should buy individual developer support from the Aimeos company:
https://aimeos.com/support
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply