install module serveral times with aliases
Posted: Mon Feb 23, 2009 7:17 am
From time to time i need use one module at serveral instances, For example, news and articles for site can be realized over module {News}. But in present time i have only two ways:
1. Copy whole folder "News" into folder "Articles" in site directory tree. After this i must check ode of module and change all links to DB, friendly names, permissions' declarations etc.
2. Work with one module {News} and divide different entities(news and articles) between different categories. And i'll get some problems on that way:
- can not set permission to different categories: so anybody who can change news, will can change articles.
- templates and additional fields will be joined in one large heap. Working with this heap can be really hard.
- if module can not use hierarchical multilevel categories and i need dividing by categories in each section, i shall create categories like "news_in city" or "articles_health". and i shall cut this prefixes in templates.
As far as i understood second way is really worse.
But edit module each time as i work with other site is really stupid work.
So i suggest extend structure of CMSModule class with method get_alias.
And as get_db_prefix() return value of get_alias() will be used in module code.
For example. Old code:
new code:
And other changes made in same way.
This architectural change make "aliasing" really easy: if we'll change return result of get_alias() we'll take new module automatically.
1. Copy whole folder "News" into folder "Articles" in site directory tree. After this i must check ode of module and change all links to DB, friendly names, permissions' declarations etc.
2. Work with one module {News} and divide different entities(news and articles) between different categories. And i'll get some problems on that way:
- can not set permission to different categories: so anybody who can change news, will can change articles.
- templates and additional fields will be joined in one large heap. Working with this heap can be really hard.
- if module can not use hierarchical multilevel categories and i need dividing by categories in each section, i shall create categories like "news_in city" or "articles_health". and i shall cut this prefixes in templates.
As far as i understood second way is really worse.
But edit module each time as i work with other site is really stupid work.
So i suggest extend structure of CMSModule class with method get_alias.
And as get_db_prefix() return value of get_alias() will be used in module code.
For example. Old code:
Code: Select all
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_news", $flds, $taboptarray);
Code: Select all
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_news_".get_alias(), $flds, $taboptarray);
This architectural change make "aliasing" really easy: if we'll change return result of get_alias() we'll take new module automatically.