O|Developer's Guide

Developers Guide

Custom Fields Display

Overview

To display a custom field or a custom field group inside the layouts, use this schema.

ITEM VIEW

Display single custom field:

 

<?php echo $this->item->fields->getOne(ID)->show();?>

Where "5" is the ID of the custom field. ID's can be found under custom fields list, the last column.

Display a group:

<?php echo $this->item->fields->showGroup("item")?>

Where "second" is the name of the group

item views/item  
items views/items  
tabs views/item under the custom tabs
features views/item under features tab

Display all:

<?=$item->fields->show()?>


Custom Fields Templates

Custom Fields Templates

Custom Fields display is being handled by the templates.

Before you start some basic HTML/CSS skills are needed.

Templates are located under the component templates directory path:

components/com_jomcomdev/templates/fields

By default there are 3 custom field templates:

When edited structure looks like this:


You can use any HTML structure and style using the component CSS files.


Custom Field styles are located in main component CSS file: assets/css/jomdirectory.css

Set Custom Field Template

To assign a template to a custom field, edit custom field in component backend under Custom Fields, then just choose the desired template:

Create a New Custom Field Template

Just copy one of the current templates, change name and edit. The new template appears under Custom Field Template.

You'll also need to create a corresponding translation in language file: components\com_jomcomdev\language \en-GB\en-GB.com_jomcomdev.ini change "en_GB" in path to match your language.

Forms

Overview

Forms used inside JomDirectory are XML based so can easily be edited.

Location of the XML files:
components/com_jomdirectory/models/forms

Each file name describes where is being used in the component front-end e.g. addreviews.xml is used for adding a review under item view.

Edit

You can edit these files and insert more fields if needed. There are Joomla based field types: text, text area, radio etc. Please read Joomla documentation for more types.

For each new field, a database column needs to be created.

Display

Form fields are being parsed by the model to the template file e.g. views/item/default.php

To display the field, use this schema:

<?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?>