Listing Input Form Modification

Top  Previous  Next

In this section you will learn how to:

 

 

See the default listing input form on the Pic.1. The /templates/[Theme Name]/classifieds/input_form_car.tpl file is used to display this form. The listing input form uses the syntax which you can see in the notes (Pic.1.) to display the fields.

 

The administrator can change field names, add new fields to this form and modify the look and feel of a field.

 

add_listing1

 

Pic.1. Default Listing Input Form.

 

 

 

Change a Caption of a Field

 

For instance, you want to change 'Seller Comments' to 'Comments', and 'Doors' to 'Number of Doors' on the 'Add Listing' page (Pic.1.).

 

 

The 'Seller Comments' field is a common field for all listing types.

 

To find common fields:

•

Go to Admin Panel -> Listing Management -> Listing Fields

To edit a field caption:

•

Open Edit listing field

•

Change the caption

The field caption will change automatically in the template (see Pic.2).

 

 

The 'Doors' field is a specific field for the 'Car' listing type.

 

To find specific fields:

•

Go to Admin Panel -> Listing Management -> Listing Types

To edit a field caption:

•

Open Edit Listing Type Info

•

Click the Edit button against the field name

•

Change the caption

The field caption will change automatically in the template (see Pic.2).

 

Notice: If you change IDs of the existing fields, you will have to change them in the templates, where these IDs are used.

 

          add_listing2

 

Pic.2. Changed Names of the Existing Listing Fields.

 

 

Add New Listing Fields

 

 

To add a new field, e.g., 'Engine Displacement' field (float type):

•

Go to Admin Panel -> Listing Management -> Listing Types

•

Open Edit Listing Type Info page of the 'Car' listing type

•

Add the new field to this type ('ID' ='EngineDisplacement', 'Caption'='Engine Displacement', 'Type'='Float')

 

 

To display this field after the 'Zip Code' field on the listing input form:

•

Open the file /templates/[Theme Name]/classifieds/input_form_car.tpl

•

Locate the following code:

 

<tr>

    <td>{$form_fields.ZipCode.caption} :</td>

    <td>{input property=ZipCode}</td>

</tr>

 

    This code displays the 'Zip Code' field (its caption and input box). (Pic.3.)

•

After it, insert the following lines:

 

<tr>

    <td>{$form_fields.EngineDisplacement.caption} :</td>

    <td>{input property=EngineDisplacement}</td>

</tr>

 

These lines display the 'Engine Displacement' field (its caption and input box). (Pic.3.)

 

If you don't specify your own template for this field, this field will be displayed like in the default template (float.tpl). Pic.3 shows how the field will look like:

 

add_listing3      

 

Pic.3. Added Listing Field.

 

 

Modify the Look and Feel of a Field

 

The look and feel of a field is determined by templates of a relevant field type. These templates are located at /templates/[Theme Name]/field_types/input . This folder contains a set of templates for each database field type.

 

 

To display input form fields, use the following syntax:

 

{input property = [Listing Field ID] template = [Your Template Name]}

 

If you do not specify the template (template = [Your Template Name]), the system will display the default template of a type.

 

E.g., the 'Price' field is the integer type and you specify {input property = Price}. As a result, the 'Price' field will be displayed according to its default template: /templates/[Theme Name]/field_types/input/integer.tpl.

 

 

To alter the way a listing field  looks like, e.g., 'Drive Type' field (list type):

•

Create a new file of  '.tpl' format in the folder   /templates/[Theme Name]/field_types/input/ (e.g.'list_radio.tpl')

•

Add the code to this file:

 

{foreach from=$list_values item=list_value}

 

    <input type="radio" name='{$id}' value='{$list_value.id}' {if $list_value.id == $value}checked{/if} > {$list_value.caption}

 

{/foreach}

 

•

Specify the newly created file as a template for the 'Drive Type' field:

▪

Open /templates/[Theme Name]/classifieds/input_form_car.tpl

▪

In it, locate the code:

<td>{input property=DriveType}</td>

▪

Replace it with following:

<td>{input property=DriveType  template='list_radio.tpl'} </td>

 

The 'Drive Type' field will be displayed as on Pic.4.

 

          add_listing4

 

Pic.4. Alter the Way a Listing Field Looks Like

 

 

Note: The above changes to the 'Add Listing' page (the listing input form) will be also displayed on the 'Edit Listing' page.