2-jFoobars Component Builder
Pour commencer nous allons lancer l'extension JFoobars Component Builder pour créer un composant com_livres.
Le programme vous explique la commande à saisir pour créer le composant:
Il suffit de saisir dans le navigateur :
http://localhost/joomla/administrator/index.php?option=com_jfoobar&singular=livre&plural=livres
Le programme génère tous les fichiers nécessaires à la gestion ainsi que la table #__livres. Dans mon le préfixe des mes tables est xxufl. Cela sera différent pour vous.
Il ouvre automatiquement le nouveau composant.
Ce nouveau composant est complet, la table gère toutes les subtilités de Joomla.
3-Table et fichiers
Voici l'affichage des champs sous phpMyAdmin:
Nous avons à cet instant un composant complètement fonctionnel avec la gestion des catégories.
Voici la liste des fichiers :
administrator\components\com_livres\access.xml
administrator\components\com_livres\config.xml
administrator\components\com_livres\controller.php
administrator\components\com_livres\controllers
administrator\components\com_livres\fichiers.txt
administrator\components\com_livres\helpers
administrator\components\com_livres\index.html
administrator\components\com_livres\language
administrator\components\com_livres\livres.php
administrator\components\com_livres\livres.xml
administrator\components\com_livres\models
administrator\components\com_livres\sql
administrator\components\com_livres\tables
administrator\components\com_livres\views
administrator\components\com_livres\controllers\index.html
administrator\components\com_livres\controllers\livre.php
administrator\components\com_livres\controllers\livres.php
administrator\components\com_livres\helpers\index.html
administrator\components\com_livres\helpers\livres.php
administrator\components\com_livres\language\da-DK
administrator\components\com_livres\language\en-GB
administrator\components\com_livres\language\es-ES
administrator\components\com_livres\language\index.html
administrator\components\com_livres\language\pt-BR
administrator\components\com_livres\language\sv-SE
administrator\components\com_livres\language\da-DK\da-DK.com_livres.ini
administrator\components\com_livres\language\da-DK\da-DK.com_livres.sys.ini
administrator\components\com_livres\language\da-DK\index.html
administrator\components\com_livres\language\en-GB\en-GB.com_livres.ini
administrator\components\com_livres\language\en-GB\en-GB.com_livres.sys.ini
administrator\components\com_livres\language\en-GB\index.html
administrator\components\com_livres\language\es-ES\es-ES.com_livres.ini
administrator\components\com_livres\language\es-ES\es-ES.com_livres.sys.ini
administrator\components\com_livres\language\es-ES\index.html
administrator\components\com_livres\language\pt-BR\index.html
administrator\components\com_livres\language\pt-BR\pt-BR.com_livres.ini
administrator\components\com_livres\language\pt-BR\pt-BR.com_livres.sys.ini
administrator\components\com_livres\language\sv-SE\index.html
administrator\components\com_livres\language\sv-SE\sv-SE.com_livres.ini
administrator\components\com_livres\language\sv-SE\sv-SE.com_livres.sys.ini
administrator\components\com_livres\models\fields
administrator\components\com_livres\models\forms
administrator\components\com_livres\models\index.html
administrator\components\com_livres\models\livre.php
administrator\components\com_livres\models\livres.php
administrator\components\com_livres\models\fields\filters.php
administrator\components\com_livres\models\fields\index.html
administrator\components\com_livres\models\fields\modal
administrator\components\com_livres\models\fields\modal\index.html
administrator\components\com_livres\models\fields\modal\livre.php
administrator\components\com_livres\models\forms\index.html
administrator\components\com_livres\models\forms\livre.xml
administrator\components\com_livres\sql\index.html
administrator\components\com_livres\sql\install.mysql.utf8.sql
administrator\components\com_livres\sql\uninstall.mysql.utf8.sql
administrator\components\com_livres\tables\index.html
administrator\components\com_livres\tables\livre.php
administrator\components\com_livres\views\livre
administrator\components\com_livres\views\livres
administrator\components\com_livres\views\livre\index.html
administrator\components\com_livres\views\livre\tmpl
administrator\components\com_livres\views\livre\view.html.php
administrator\components\com_livres\views\livre\tmpl\edit.php
administrator\components\com_livres\views\livre\tmpl\edit_custom_fields.php
administrator\components\com_livres\views\livre\tmpl\edit_metadata.php
administrator\components\com_livres\views\livre\tmpl\edit_parameters.php
administrator\components\com_livres\views\livre\tmpl\edit_publishing.php
administrator\components\com_livres\views\livre\tmpl\index.html
administrator\components\com_livres\views\livres\index.html
administrator\components\com_livres\views\livres\tmpl
administrator\components\com_livres\views\livres\view.html.php
administrator\components\com_livres\views\livres\tmpl\default.php
administrator\components\com_livres\views\livres\tmpl\default_batch.php
administrator\components\com_livres\views\livres\tmpl\index.html
administrator\components\com_livres\views\livres\tmpl\modal.php
components\com_livres\controller.php
components\com_livres\controllers
components\com_livres\fichiers.txt
components\com_livres\helpers
components\com_livres\index.html
components\com_livres\language
components\com_livres\livres.php
components\com_livres\models
components\com_livres\router.php
components\com_livres\views
components\com_livres\controllers\index.html
components\com_livres\controllers\livre.php
components\com_livres\helpers\index.html
components\com_livres\helpers\livres.php
components\com_livres\helpers\route.php
components\com_livres\language\da-DK
components\com_livres\language\en-GB
components\com_livres\language\es-ES
components\com_livres\language\index.html
components\com_livres\language\pt-BR
components\com_livres\language\sv-SE
components\com_livres\language\da-DK\da-DK.com_livres.ini
components\com_livres\language\da-DK\da-DK.com_livres.sys.ini
components\com_livres\language\da-DK\index.html
components\com_livres\language\en-GB\en-GB.com_livres.ini
components\com_livres\language\en-GB\en-GB.com_livres.sys.ini
components\com_livres\language\en-GB\index.html
components\com_livres\language\es-ES\es-ES.com_livres.ini
components\com_livres\language\es-ES\es-ES.com_livres.sys.ini
components\com_livres\language\es-ES\index.html
components\com_livres\language\pt-BR\index.html
components\com_livres\language\pt-BR\pt-BR.com_livres.ini
components\com_livres\language\pt-BR\pt-BR.com_livres.sys.ini
components\com_livres\language\sv-SE\index.html
components\com_livres\language\sv-SE\sv-SE.com_livres.ini
components\com_livres\language\sv-SE\sv-SE.com_livres.sys.ini
components\com_livres\models\form.php
components\com_livres\models\forms
components\com_livres\models\index.html
components\com_livres\models\livre.php
components\com_livres\models\livres.php
components\com_livres\models\forms\index.html
components\com_livres\models\forms\livre.xml
components\com_livres\views\form
components\com_livres\views\livre
components\com_livres\views\livres
components\com_livres\views\form\index.html
components\com_livres\views\form\tmpl
components\com_livres\views\form\view.html.php
components\com_livres\views\form\tmpl\edit.php
components\com_livres\views\form\tmpl\edit.xml
components\com_livres\views\form\tmpl\edit_custom_fields.php
components\com_livres\views\form\tmpl\edit_metadata.php
components\com_livres\views\form\tmpl\edit_parameters.php
components\com_livres\views\form\tmpl\edit_publishing.php
components\com_livres\views\form\tmpl\index.html
components\com_livres\views\livre\index.html
components\com_livres\views\livre\tmpl
components\com_livres\views\livre\view.html.php
components\com_livres\views\livre\view.json.php
components\com_livres\views\livre\tmpl\default.php
components\com_livres\views\livre\tmpl\default.xml
components\com_livres\views\livre\tmpl\index.html
components\com_livres\views\livres\index.html
components\com_livres\views\livres\tmpl
components\com_livres\views\livres\view.feed.php
components\com_livres\views\livres\view.html.php
components\com_livres\views\livres\tmpl\default.php
components\com_livres\views\livres\tmpl\default.xml
components\com_livres\views\livres\tmpl\index.html
media\com_livres\css
media\com_livres\fichiers.txt
media\com_livres\images
media\com_livres\index.html
media\com_livres\js
media\com_livres\css\administrator.css
media\com_livres\css\index.html
media\com_livres\images\16
media\com_livres\images\48
media\com_livres\images\index.html
media\com_livres\images\16\index.html
media\com_livres\images\16\livres.png
media\com_livres\images\48\index.html
media\com_livres\images\48\livres.png
media\com_livres\js\index.html
Nous avons besoin maintenant de 2 autres tables : xxufl_auteurs et xxufl_chapitres. Pour cela nous allons copier la structure de xxufl_livres dans ces nouvelles tables avec phpMyAdmin.
4-Création autres tables
Après avoir ouvert phpMyAdmin sur la table xxufl_livres, nous allons dans Opérations puis Copier la table vers en choisissant Structure seule :
Puis :
Nous avons maintenant nos 3 tables. Les tables xxufl_livres et xxufl_auteurs seront gérées avec une interface standard tandis que xxufl_chapitres sera alimentée par l'interface de gestion de xxufl_livres.
5-Ajout nouveaux champs
Nous avons besoin de lier la table xxufl_livres avec la table xxufl_auteurs. Pour cela nous allons créer un champ supplémentaire dans la table xxufl_livres : id_auteur.
Nous avons besoin de lier la table xxufl_chapitres avec la table xxufl_livres . Pour cela nous allons créer un champ supplémentaire dans la table xxufl_livres : id_livre.
La structure des tables est donc la suivante:
Nous avons fini les préparatifs pour nous lancer dans la programmation du composant Livres.