Positions Management

 

What is a position?

A "position" is an area of the component Smarty template where certain fields assigned to it will automatically render and display.
At installation of Ads Factory 1.5.0 there are by default installed two positions and included in the templates of their scope:

  • Listing Middle ( listingmiddle ) in t_listadds.tpl
  • Details Page Header ( defdetailspageheader ) in t_details_add.tpl

A position, in order to display fields must

  • exist in database ( check in Positions / Position Definitions Manager ); for achieving that read this
  • have the Smarty snippet that include the position ( ex: {include file='elements/display_fields.tpl' position='listingmiddle' this_add=$item->id} ); for achieving that read this
  • have fields assigned to it

 

Management of positions

Management of positions implies creation new positions or editing a field display from a position.

Access to this section is from Sections / Page positions:

Image

Creating New positions
Press the "New position" link from the "Page positions" section and fill the details of the new to be created position.
Of importance are the unique name field, the template for wich the position is and the Position item layout.
Verify is just a flag that get's setup to "Yes" on the first loading of a page with the position on it.
Image

A position can be deleted. The snippet code is left to be cleared manually. ( for cleaning template should be): after deleting the database records of the position you will be pointed for the snippet to look for in the template.

Position displaying in templates
After a position information is stored in the database, the position must be included in the template in the area you need / like.
If you are familiar with HTML this should be very simple.
Otherwise a look on the template will give you a hint on location areas of the template for that actual HTML knowledge not been necessary.
For instance if you want your new position bellow the category name when looking at the details page, it is kind expectable to search in the t_details_add.tpl for "category" or "cat" or "catname" occurrences and see if it sounds with what do you see on the page.
If you are using the template editor from the component, point your cursor there and insert the position with the snippet tool
or insert the actual Smarty if you have it in clipboard.
Evidently you can use any PHP / text editor for inserting the Smarty position code.
Image

Observations

Debugging / previewing a position place: Instead of introducing the position Smarty snippet you can insert some valid HTML just to see how it will be visualized on front.
Inserting something like : LABEL : VALUE should give you a visual on how it would look when it will be rendered with fields.

Adding surrounding HTML, CSS properties: The "Insert at cursor" tool just inserts the position renderer meaning this:
{include file='elements/display_fields.tpl' position='defdetailspageheader'}
You could add extra html arround this like:

<div>
{include file='elements/display_fields.tpl' position='defdetailspageheader'}
</div>

Or CSS properties

<span style="color:#DEDEDE important!;" >
{include file='elements/display_fields.tpl' position='defdetailspageheader'}
</span>

Or even JavaScript

<p onmouseover="alert('These are some custom fields!');" >
{include file='elements/display_fields.tpl' position='defdetailspageheader'}
</p>

The snippet must be inserted in HTML valid positions:
Some of the infinite examples of invalid positions ( see where "HERE" is ):

  • <a href="/HERE">Some link</a>
  • {$add->wash_hands HERE}
  • <table>
    HERE
    <tr>
    HERE
    <td>bla bla</td>
    HERE
    <td>bla bla</td>
    </tr>
    </table>

For the listing templates: The snippet must be inserted between the {foreach} smarty tags ( {foreach .. } and {/foreach} ) so the custom fields of each item will be displayed!

Custom Fields assigning to positions

Custom fields can be setup to be displayed automatically to a certain position by just assigning the field to that position. For Ads Factory 1.5.0 new installations, there can already be assigned fields to the default installed positions (Listing Middle - listingmiddle and Details Page Header - defdetailspageheader). When other positions created, fields can be assigned to those too. 

Image 


In section "Positions / Fields positioning" you can do this: 

Image

A field can be assigned to all the positions available.

Revised "Ads Factory" version 1.5.0.