Custom configuration

19/04/2011

Our web-to-print extension for Magento can use custom configuration data from a special custom-options.xml file in order to override, activate or deactivate special web-to-print features.

This file is intended to provide a way of storing rarely used configuration options without bloating the admin interface. Name of the file is custom-options.xml and it should be added manually to /app/code/community/ZetaPrints/WebToPrint/etc folder of your Magento installation.

The only required nodes in the file are <config> and <webtoprint>. Sample configuration file content:

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0"?>
<!-- Sample options file, not to be included in extension distribution -->
<config>
<webtoprint>
<cache type="user">
<enabled>0</enabled>
</cache>
<colorpicker>
<show>0</show>
</colorpicker>
</webtoprint>
</config>

Everything between <webtoprint> can be retrieved using getOptions method of ZetaPrints_WebToPrint_Model_Config class. There is a method added in app/code/community/ZetaPrints/WebToPrint/Helper/Data.php file, to handle this. Method name is

1
getCustomOptions($path = null)

It accepts optional parameter $path that allows to search for specific config node. For example, in the sample configuration file above, to search for enabled node of cache node you should pass cache/enabled as parameter of the method. Currently, the method is used to retrieve all stored values. Configuration is returned as SimpleXMLElement object that has all nodes as public members and can be encoded to JSON without modification.

XML schema

Users who use special XML editors could use XSD file as a helper while editing custom-options.xml file. Scheme is available here.

Web-to-print custom configuration examples

Currently, you can use this custom configuration file to:

See thisĀ  XML schema for full and detailed list of up to date configuration settings.

See also: