Provides assistance developing themes for your site.
- Download Tweak.
- Create a folder named
tweak
in themodules
directory. - Extract all files into the
modules/tweak
directory (modules/tweak/readme.md
should exist). - Customize your
site:settings
partial in the CMS, as described in theUsage
section. - Done!
You can use the site:settings
partial any way you want, for example:
<?
return (object) array(
'date' => date('F, j'),
'charset' => 'utf-8',
'company' => (object) array(
'title' => Shop_CompanyInformation::get()->name,
'slogan' => '',
'sales_email' => '[email protected]',
'info_email' => '[email protected]',
'twitter_page' => 'http://twitter.com/',
'facebook_page' => 'http://facebook.com/',
'youtube_page' => 'http://www.youtube.com/'
),
'customer' => (object) array(
'default_email' => 'E-mail address', // display on home, login, register pages
),
'meta' => (object) array(
'default_description' => "",
'default_keywords' => "",
),
'search' => (object) array(
'path' => '/search',
'products_per_page' => 6
),
'store' => (object) array(
'path' => '/store',
'product_path' => '/store/product',
'category_path' => '/store/category',
'cart_path' => '/store/cart',
'checkout_path' => '/store/checkout',
'pay_path' => '/store/pay',
'product_considered_new' => 7 * 24 * 60 * 60,
'invoice' => (object) array(
'product' => (object) array(
'max_title_length' => 999,
'max_description_length' => 999,
'default_thumb_path' => 'resources/ui/product-default-thumb.png',
'image' => (object) array(
'width' => 87,
'height' => 87
)
)
),
'category' => (object) array(
'products_per_page' => 11,
'max_title_length' => 24,
'default_thumb_path' => '/resources/ui/category-default-thumb.jpg',
'image' => (object) array(
'small_width' => 20,
'small_height' => 20,
'large_width' => 40,
'large_height' => 40
),
'product' => (object) array(
'max_title_length' => 999,
'max_description_length' => 999,
'default_thumb_path' => 'resources/ui/product-default-thumb.png',
'image' => (object) array(
'width' => 87,
'height' => 87
)
)
),
'product' => (object) array(
'default_thumb_path' => 'resources/ui/product-detail-default-thumb.png',
'image' => (object) array(
'small_width' => 60,
'small_height' => 60,
'medium_width' => 385,
'medium_height' => 350,
'large_width' => 385 * 3,
'large_height' => 350 * 3
),
'related' => (object) array(
'max_title_length' => 999,
'max_description_length' => 23,
'per_page' => 8,
'default_thumb_path' => '/resources/ui/product-default-thumb.png',
'discount_path' => '/resources/ui/price-strike.png',
'image' => (object) array(
'width' => 145,
'height' => 145
)
)
),
'frontpage' => (object) array(
'max_title_length' => 999,
'max_description_length' => 23,
'default_thumb_path' => '/resources/ui/product-default-thumb.png',
'discount_path' => '/resources/ui/price-strike.png',
'image' => (object) array(
'width' => 116,
'height' => 113
)
),
'cart' => (object) array(
'product' => (object) array(
'max_title_length' => 999,
'max_description_length' => 999,
'default_thumb_path' => '/resources/ui/product-default-thumb.png',
'image' => (object) array(
'width' => 55,
'height' => 45
)
)
)
),
'blog' => (object) array(
'path' => '/blog/',
'per_page' => 5,
'preview' => (object) array(
'trim_length' => 300
),
'rss' => (object) array(
'per_page' => 20
)
),
'account' => (object) array(
'path' => '/account',
'orders_path' => '/account/orders',
'order_path' => '/account/order'
)
);
Then you can use the site settings globally (in your templates) like this:
<h1><?= $site_settings->company->title ?></h1>
There is minor support for text alias content replacement. For example, the HTML below will output the associated alias content:
Site URL: [site_url]<br />
Root URL: [root_url]<br />
Customer First Name: [customer.first_name]<br />
Customer Last Name: [customer.last_name]<br />
Here is the complete listing:
[site_url]
- provides the URL of the installation, including domain.[root_url]
- provides the path of the installation from the root domain.[customer.first_name]
- provides the first name of the currently logged in customer.[customer.last_name]
- provides the first name of the currently logged in customer.
You can add your own aliases by creating your own custom module, and binding on the tweak:onGetAliases
event. From that callback, return an array of your replacements. For example:
return array(
'my_special_url' => root_url('/my_special_url')
);