08 - Du coté du public
Il faut d'abord modifier le fichier model.
components/com_prestalegals/models/prestalegal.php
Pour la partie publique, c'est ce fichier qu'il faut modifier.
Le début de la fonction getItemQuery :
function getItemQuery($id) { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.subtitle, ' . 'a.snippet, a.fulltext, ' . 'a.checked_out, a.checked_out_time, ' . 'a.access, a.asset_id, a.version, a.language, a.ordering, ' . 'a.metakey, a.metadesc, a.metadata, ' . 'a.parameters, a.custom_fields' ) ); $query->from('#__prestalegals AS a');
devient :
function getItemQuery($id) { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.catid, ' . 'a.created, a.created_by, a.created_by_alias, '. 'a.modified, a.modified_by, '. 'a.checked_out, a.checked_out_time, ' . 'a.state, a.publish_up, a.publish_down, ' . 'a.access, a.asset_id, a.version, a.language, a.ordering, ' . 'a.metakey, a.metadesc, a.metadata, ' . 'a.parameters,' . 'a.company_status, a.company_name,' . 'a.company_director, a.company_address,' . 'a.company_address_complement, a.company_postbox,' . 'a.company_postcode, a.company_town,' . 'a.company_state, a.company_country,' . 'a.company_phone, a.company_fax,' . 'a.company_mobile, a.company_email,' . 'a.company_url, a.company_siren,' . 'a.company_siret, a.company_ape,' . 'a.company_tva, a.company_capital,' . 'a.company_cnil, a.bank_name,' . 'a.editor_name, a.editor_address,' . 'a.editor_address_complement, a.editor_postbox,' . 'a.editor_postcode, a.editor_city,' . 'a.editor_country, a.editor_email,' . 'a.editor_phone, a.editor_fax,' . 'a.editor_url, a.host_name,' . 'a.host_address, a.host_address_complement,' . 'a.host_postbox, a.host_postcode,' . 'a.host_city, a.host_country,' . 'a.host_email, a.host_phone,' . 'a.host_fax, a.host_url,' . 'a.legals_title, a.legals_display_title,' . 'a.legals_alias, a.legals_meta_title,' . 'a.legals_meta_description, a.legals_meta_keywords,' . 'a.use_terms, a.use_policy, a.use_delivery' ) ); $query->from('#__prestalegals AS a');
Il faut ensuite, comme dans la partie administration, modifier le fichier components/com_prestalegals/models/forms/prestalegal.xml pour prendre en compte la suppression de certains champs et la création des nouveaux.
components/com_prestalegals/views/prestalegal/view.html.php
Il faut rajouter l'appel au css comme ceci :
JHTML::stylesheet('media/com_prestalegals/css/template.css'); parent::display($tpl);
Il faut rajouter la fonction (merci NeoJoomla) suivante :
function displayInfo( $string, $info, $type='' ) { if ( !$info || $info == 'http://' ) return; switch( $type ) { case 'url' : ; $info = '<a href="'.$info.'" target="_blank">'.$info.'</a>'; break; case 'email' : $info = JHTML::_( 'email.cloak', $info, 0 ); break; } return '<div class="block"><label>'.$string.'</label><data>'.$info.'</data></div>'; if ( $type == "http://" ) $target = 'target="_blank"'; if ( $info && $type != '' && (substr($info, 0, strlen($type)) != $type) ) { $info = '<a href="'.$type.$info.'" '.$target.'>'.$info.'</a>'; } echo $string.' : '.$info.'<br />'; return; }
Création du fichier media/com_prestalegals/css/template.css
Renseigner le fichier comme ceci :
@charset "UTF-8"; /* @package Joomla @subpackage com_prestalegals @copyright Copyright (C) 2013 Gilbert Marin. All rights reserved. @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html */ /* -- ICON STYLES ----------------------------- */ .icon-16-prestalegals { background-image: url(../images/16/prestalegals.png); } /* -- HEADER ICON STYLES ----------------------------- */ .icon-48-prestalegal { background-image: url(../images/48/prestalegals.png); } .icon-48-prestalegal-add { background-image: url(../images/48/prestalegals.png); } .icon-48-prestalegal-edit { background-image: url(../images/48/prestalegals.png); } div.block{ overflow:hidden; } div.block label{ width:220px; display:block; float:left; text-align:center; background: #f2f2f2; border-bottom:1px solid #eee; color: #666; } div.block data{ display:block; float:left; text-align:left; margin-left: 10px; border-bottom:1px solid #eee; } div.block .input{ margin-left:4px; float:left; } .sectiontableheader{ margin-bottom: 10px; background: #efefef; color: #333; font-weight: bold; padding: 4px; border-right: 1px solid #fff; padding-left: 10px; }
Modification du fichier components/com_prestalegals/views/prestalegal/tmpl/default.php
J'ai choisi d'afficher les informations dans des onglets.
Je défini d'abord des variables qui sont vraies si au moins un des champs de chaque partie est renseigné.
Les variables :
- $display_company_prestalegals
- $display_contact_prestalegals
- $display_editor_prestalegals
- $display_host_prestalegals
- $display_useterms_prestalegals
- $display_usepolicy_prestalegals
- $display_usedelivery_prestalegals
Je défini le système d'onglets :
<?php jimport( 'joomla.html.html.tabs' ); $options = array( 'onActive' => 'function(title, description){ description.setStyle("display", "block"); title.addClass("open").removeClass("closed"); }', 'onBackground' => 'function(title, description){ description.setStyle("display", "none"); title.addClass("closed").removeClass("open"); }', 'startOffset' => 0, // 0 starts on the first tab, 1 starts the second, etc... 'useCookie' => true, // this must not be a string. Don't use quotes. ); echo JHtml::_('tabs.start', 'tab_group_id', $options); ?>
Le premier onglet :
<?php if ( $display_company_prestalegals ) { ?> <?php echo JHtml::_('tabs.panel', JText::_('COM_PRESTALEGALS_FIELDSET_COMPANY'), 'panel_company');?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_COMPANY');?></div> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_STATUS_LABEL' ), $this->item->company_status ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_NAME_LABEL' ), $this->item->company_name ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_DIRECTOR_LABEL' ), $this->item->company_director ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_CAPITAL_LABEL' ), $this->item->company_capital ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_SIREN_LABEL' ), $this->item->company_siren ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_SIRET_LABEL' ), $this->item->company_siret ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_APE_LABEL' ), $this->item->company_ape ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_TVA_LABEL' ), $this->item->company_tva ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_COMPANY_CNIL_LABEL' ), $this->item->company_cnil ); ?> <?php } ?> <br> <?php if ( $display_contact_prestalegals ) { ?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_CONTACT');?></div> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_ADRESS_LABEL' ), $this->item->company_address ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_ADRESS_COMPLEMENT_LABEL' ), $this->item->company_address_complement ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_POSTBOX_LABEL' ), $this->item->company_postbox ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_POSTCODE_LABEL' ), $this->item->company_postcode ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_TOWN_LABEL' ), $this->item->company_town ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_STATE_LABEL' ), $this->item->company_state ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_COUNTRY_LABEL' ), $this->item->company_country ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_PHONE_LABEL' ), $this->item->company_phone ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_FAX_LABEL' ), $this->item->company_fax ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_MOBILE_LABEL' ), $this->item->company_mobile ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_EMAIL_LABEL' ), $this->item->company_email ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_CONTACT_URL_LABEL' ), $this->item->company_url ); ?> <?php } ?> <br> <?php if ( $display_editor_prestalegals ) { ?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_EDITOR');?></div> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_NAME_LABEL' ), $this->item->editor_name ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_ADRESS_LABEL' ), $this->item->editor_address ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_ADRESS_COMPLEMENT_LABEL' ), $this->item->editor_address_complement ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_POSTBOX_LABEL' ), $this->item->editor_postbox ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_POSTCODE_LABEL' ), $this->item->editor_postcode ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_CITY_LABEL' ), $this->item->editor_city ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_COUNTRY_LABEL' ), $this->item->editor_country ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_EMAIL_LABEL' ), $this->item->editor_email ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_PHONE_LABEL' ), $this->item->editor_phone ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_FAX_LABEL' ), $this->item->editor_fax ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_EDITOR_URL_LABEL' ), $this->item->editor_url ); ?> <?php } ?> <br> <?php if ( $display_host_prestalegals ) { ?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_HOST');?></div> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_NAME_LABEL' ), $this->item->host_name ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_ADRESS_LABEL' ), $this->item->host_address ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_ADRESS_COMPLEMENT_LABEL' ), $this->item->host_address_complement ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_POSTBOX_LABEL' ), $this->item->host_postbox ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_POSTCODE_LABEL' ), $this->item->host_postcode ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_CITY_LABEL' ), $this->item->host_city ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_COUNTRY_LABEL' ), $this->item->host_country ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_EMAIL_LABEL' ), $this->item->host_email ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_PHONE_LABEL' ), $this->item->host_phone ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_FAX_LABEL' ), $this->item->host_fax ); ?> <?php echo $this->displayInfo( JText::_( 'COM_PRESTALEGALS_FIELD_HOST_URL_LABEL' ), $this->item->host_url ); ?> <?php } ?>
Le deuxième onglet :
<?php if ( $display_useterms_prestalegals ) { ?> <?php echo JHtml::_('tabs.panel', JText::_('COM_PRESTALEGALS_FIELDSET_USETERMS'), 'panel_useterms');?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_USETERMS');?></div> <div class="block"> <?php echo $this->item->use_terms; ?> </div> <?php } ?>
Le troisième onglet :
<?php if ( $display_usepolicy_prestalegals ) { ?> <?php echo JHtml::_('tabs.panel', JText::_('COM_PRESTALEGALS_FIELDSET_POLICY'), 'panel_usepolicy');?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_POLICY');?></div> <div class="block"> <?php echo $this->item->use_policy; ?> </div> <?php } ?>
Et enfin le dernier :
<?php if ( $display_usedelivery_prestalegals ) { ?> <?php echo JHtml::_('tabs.panel', JText::_('COM_PRESTALEGALS_FIELDSET_DELIVERY'), 'panel_usedelivery');?> <div class="sectiontableheader"><?php echo JText::_('COM_PRESTALEGALS_FIELDSET_DELIVERY');?></div> <div class="block"> <?php echo $this->item->use_delivery; ?> </div> <?php } ?>
Et pour terminer le système d'onglet :
<?php echo JHtml::_('tabs.end');?>
Voila je ne pense pas avoir oublier quoi que ce soit.
Vous pouvez recevoir le composant complet près à l'utilisation.
Saisissez un commentaire avec une adresse valide pour que je puisse vous envoyer le composant par email.