Page 1 of 1

Not allowed to access configuration

Posted: 27 Aug 2016, 23:05
by jossnaz
i am trying to write my own config setting and read it from my custom body template.

Side question: i have defined my template body like this (shop.php):

Code: Select all

  'client' => array(
    'html' => array(
      'checkout' => array(
        'standard' => array(
          'address' => array(
            'standard' => array(
              'template-body' => array(
                __DIR__ . "/../ext/cmc-usa-salestax-by-state/client/html/templates/checkout/standard/address-billing-body-default.php"
              )
            )
i thought just leaving it in the right directory will load that template?! that is without specifying the directory in shop.php like i did above. That is for extensions. See here https://aimeos.org/docs/Developers/Html ... _templates


anyway:

when adding a config:

Code: Select all

  'mshop' => array(
    'price' => array(
      'taxflag' => 0,
      'shoplocatedinusa' => 1,
    )
  )
and then accessing it in my address-billing-body-default.php results in
Not allowed to access "mshop/price/shoplocatedinusa" configuration

Re: Not allowed to access configuration

Posted: 28 Aug 2016, 00:59
by aimeos
jossnaz wrote: i thought just leaving it in the right directory will load that template?! that is without specifying the directory in shop.php like i did above. That is for extensions. See here https://aimeos.org/docs/Developers/Html ... _templates
That's right, it's enough to copy the template in your extension into the ./client/html/templates/checkout/standard/ directory. The only thing I'm currently thinking about is if it's necessary to have this in the manifest.php of your extension to ensure your extension templates are loaded after that of ai-client-html:

Code: Select all

	'depends' => array(
		'aimeos-core',
		'ai-client-html',
	),
jossnaz wrote: when adding a config:

Code: Select all

  'mshop' => array(
    'price' => array(
      'taxflag' => 0,
      'shoplocatedinusa' => 1,
    )
  )
Not allowed to access "mshop/price/shoplocatedinusa" configuration
Within the ai-client-html, you can only access configuration settings starting with "client/". This is enforced by the "Protect" config decorator and should prevent developers from trying to retrieve the database credentials and execute SQL in the templates :-)

Re: Not allowed to access configuration

Posted: 28 Aug 2016, 04:12
by jossnaz
seems too restrictive to me.

I hope i can access the config from my plugin... say, to check that the user has set the configuration correctly before proceeding to do stuff.

Re: Not allowed to access configuration

Posted: 28 Aug 2016, 09:57
by aimeos
If you want to add own configuration for your templates, please use the prefix "client/html/_..." instead. The "mshop/..." configuration settings are only for the data access layer in "./lib/mshoplib" of the Aimeos core.