Dernière mise à jour : 30/11/2013 à 14h25
Table des matières
La théorie
Il est possible de dupliquer un module, soit pour le renommer à son goût, soit pour utiliser simultanément plusieurs fois le même module dans des situations différentes .
Il suffit de remplacer le nom du module partout où il apparaît en respectant bien la casse (majuscules/minuscules), dans sa version non-installée.
Vous n'avez besoin d'aucune connaissance particulière en programmation, mais il va falloir être méthodique sachant que chaque oubli ou suppression d'un autre caractère entraînera une erreur.
Outil : notepad++
La pratique
Exemple avec le module news transformé en module blog.
- Télécharger le module news officiel
- Décompresser l'archive
- Modifier le nom du dossier news en blog
Le contenu des fichiers
Il faut effectuer le remplacement de trois chaînes de caractères dans tous les fichiers du module : module, Module et MODULE.
- Ouvrir notepad++
- Cliquer sur le menu Recherche > Rechercher...
- Cliquer sur l'onglet Rechercher dans les fichiers d'un dossier
- Choisir le Dossier blog
- Cocher la case Respecter la casse
Effectuer les 3 recherches suivantes :
- Rechercher news, remplacer tout par blog
- Rechercher News, remplacer tout par Blog
- Rechercher NEWS, remplacer tout par BLOG
Grâce au bouton Remplacer tout, la manipulation est très rapide pour chaque recherche.
Une recherche, sans respect de la casse, sur news permet de s'assurer que tout est modifié.
Le nom des fichiers
Renommer tous les fichiers qui contiennent le mot news, News ou NEWS, dans leur nom avec le mot correspondant pour le module blog (news_block.tpl devient blog_block.tpl, NewsSetup.class.php devient BlogSetup.class.php, etc.).
__news
Caché :
____lang
______english
________desc.ini
________install.php
________news_config.php
________news_english.php
______french
________desc.ini
________install.php
________news_config.php
________news_french.php
____phpboost
______NewsCats.class.php
______NewsCommentsTopic.class.php
______NewsExtensionPointProvider.class.php
______NewsFeedProvider.class.php
______NewsHomePageExtensionPoint.class.php
______NewsSearchable.class.php
______NewsSetup.class.php
______NewsSitemapExtensionPoint.class.php
____templates
______framework
________content
__________syndication
____________last_news.tpl
______images
______admin_news.tpl
______admin_news_cat.tpl
______admin_news_config.tpl
______admin_news_menu.tpl
______management.tpl
______news.css
______news.tpl
______news_block.tpl
______news_list.tpl
____admin_news.php
____admin_news_cat.php
____admin_news_config.php
____admin_news_menu.php
____config.ini
____index.php
____management.php
____news.php
____news.png
____news_begin.php
____news_constants.php
____news_mini.png
____print.php
____xmlhttprequest.php
____xmlhttprequest_cats.php
______english
________desc.ini
________install.php
________news_config.php
________news_english.php
______french
________desc.ini
________install.php
________news_config.php
________news_french.php
____phpboost
______NewsCats.class.php
______NewsCommentsTopic.class.php
______NewsExtensionPointProvider.class.php
______NewsFeedProvider.class.php
______NewsHomePageExtensionPoint.class.php
______NewsSearchable.class.php
______NewsSetup.class.php
______NewsSitemapExtensionPoint.class.php
____templates
______framework
________content
__________syndication
____________last_news.tpl
______images
______admin_news.tpl
______admin_news_cat.tpl
______admin_news_config.tpl
______admin_news_menu.tpl
______management.tpl
______news.css
______news.tpl
______news_block.tpl
______news_list.tpl
____admin_news.php
____admin_news_cat.php
____admin_news_config.php
____admin_news_menu.php
____config.ini
____index.php
____management.php
____news.php
____news.png
____news_begin.php
____news_constants.php
____news_mini.png
____print.php
____xmlhttprequest.php
____xmlhttprequest_cats.php
Ça fait du monde

Une fois TOUS les fichiers vérifiés et modifiés, le répertoire blog ressemble à ça :
__blog
Caché :
____lang
______english
________desc.ini
________install.php
________blog_config.php
________blog_english.php
______french
________desc.ini
________install.php
________blog_config.php
________blog_french.php
____phpboost
______BlogCats.class.php
______BlogCommentsTopic.class.php
______BlogExtensionPointProvider.class.php
______BlogFeedProvider.class.php
______BlogHomePageExtensionPoint.class.php
______BlogSearchable.class.php
______BlogSetup.class.php
______BlogSitemapExtensionPoint.class.php
____templates
______framework
________content
__________syndication
____________last_blog.tpl
______images
______admin_blog.tpl
______admin_blog_cat.tpl
______admin_blog_config.tpl
______admin_blog_menu.tpl
______management.tpl
______blog.css
______blog.tpl
______blog_block.tpl
______blog_list.tpl
____admin_blog.php
____admin_blog_cat.php
____admin_blog_config.php
____admin_blog_menu.php
____config.ini
____index.php
____management.php
____blog.php
____blog.png
____blog_begin.php
____blog_constants.php
____blog_mini.png
____print.php
____xmlhttprequest.php
____xmlhttprequest_cats.php
______english
________desc.ini
________install.php
________blog_config.php
________blog_english.php
______french
________desc.ini
________install.php
________blog_config.php
________blog_french.php
____phpboost
______BlogCats.class.php
______BlogCommentsTopic.class.php
______BlogExtensionPointProvider.class.php
______BlogFeedProvider.class.php
______BlogHomePageExtensionPoint.class.php
______BlogSearchable.class.php
______BlogSetup.class.php
______BlogSitemapExtensionPoint.class.php
____templates
______framework
________content
__________syndication
____________last_blog.tpl
______images
______admin_blog.tpl
______admin_blog_cat.tpl
______admin_blog_config.tpl
______admin_blog_menu.tpl
______management.tpl
______blog.css
______blog.tpl
______blog_block.tpl
______blog_list.tpl
____admin_blog.php
____admin_blog_cat.php
____admin_blog_config.php
____admin_blog_menu.php
____config.ini
____index.php
____management.php
____blog.php
____blog.png
____blog_begin.php
____blog_constants.php
____blog_mini.png
____print.php
____xmlhttprequest.php
____xmlhttprequest_cats.php
Ajustements
Il y a quelques réajustement à faire dans les fichier de langues (news est féminin, blog est masculin
)Changer les icônes blog.png et blog_mini.png si besoin.
Installation
Ajouter le dossier à la racine du site.
Il ne reste plus qu'a tester en installant le module via l'administration du site.
Les mises à jours
Vous devrez refaire la manipulation sur les fichiers modifiés par la mise à jour si le module dupliqué (news) est impacté.
La configuration et la création de la base de donnée du nouveau module (blog) étant déjà effectuées, il suffit de remplacer les fichier sans avoir besoin de réinstaller le module (sauf en cas de mise à jour impactant la base de données).
Bonus
Module blog
Module blog : télécharger.
Icônes (16 32 64px) : télécharger, à placer dans blog/templates/images.
Appel des 5 derniers billets du blog dans HomeCustom
Fichier HomeCustomHomePageExtensionPoint.class.php :
Code PHP :
<?php /*################################################## * HomeCustomHomePageExtensionPoint.class.php * ------------------- * begin : August 25, 2012 * copyright : (C) 2012 Kevin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class HomeCustomHomePageExtensionPoint implements HomePageExtensionPoint { public function get_home_page() { return new DefaultHomePage($this->get_title(), $this->get_view()); } private function get_title() { return LangLoader::get_message('title', 'common', 'HomeCustom'); } private function get_view() { $template = new FileTemplate('HomeCustom/home.tpl'); return $this->build_view($template); } private function build_view(View $template) { $result = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp, img, user_id FROM ' . PREFIX . 'blog WHERE visible = 1 ORDER BY timestamp DESC LIMIT 5 '); while ($row = $result->fetch()) { $date = new Date(DATE_TIMESTAMP, TIMEZONE_AUTO, $row['timestamp']); $template->assign_block_vars('blog', array( 'U_LINK' => Url::to_absolute('/blog/blog.php?id=' . $row['id']), 'TITLE' => $row['title'], 'CONTENT' => $row['contents'], 'IMG' => FormatingHelper::second_parse_url($row['img']), 'DATE' => $date->format(DATE_FORMAT_TEXT_LONG) )); } return $template; } } ?>
Fichier home.tpl :