Best place for getStoreConfig - block or model
When creating a magento module i sometimes need store config values for use in a template file. Where would be the best place for this - should I create a model or is a helper or block good enough?
I thinking in ter开发者_JAVA技巧ms of best practice?
I would say a helper because it is accessible from everywhere. It wouldn't be hurtful to place in a block if it's only ever used in that block or it's template, although there is not much reason to create a block just for this when a helper will do.
A model should only be used to model things. As a rule of thumb I only use models for objects that might be used in a data structure, not as a convenience holder for functions.
Template should (whenever possible) get everything from block to keep it simple and little clogged... In the block you might call the helper for getting the config value if you think that will enhance reuse ability.
精彩评论