10 - Creation relation field to link Agent and Estate

Voting
Average rating
  • 1
  • 2
  • 3
  • 4
  • 5
87 10 - Creation relation field to link Agent and Estate /realestate/demoj4/how-to-do-same-site/87-10-creation-relation-field-to-link-agent-and-estate.html
Click to subscribe
Last modified
Wednesday, 20 January 2021

Relation and relation inverse field is a powerfull feature to create link between item. More other we have a basic template system to display any field of linked item !

You can do a carroussel, a list a mansory display with any values. In this cas we will link Estate et Agent to display relation between twice

Ex display name and form of agent linkted to Estate

or display all Estate of this agent in his page

Yes starting

  1. Create a field and set Agent 
  2. Select REaltion type
  3. Assign to Estate content

In Editing type you will allow to link Estate only with Agent

  1. Editing tab
  2. Category selector
  3. Select your category

After we can configure displaying, basicly relation display only title and link, explain that we can do more

  1. Go to viewing tab
  2. Related items list
  3. Put your html code here

 

its a basic html for item displayed

now lets decript how to display more

__display_text__: is replaced with custom text created according to parameters

{{fieldname}}or{{fieldname##displayvar}} : is replaced with HTML display of each field

{{fieldname##label}} : is replaced with label of each field

%%language_string%% : is replaced with the language string

Finally, you can use item related replacements: __item_url__, __item_title_escaped__, __item_tooltip__ and item properties like: {item->id}, {item->title}, etc

In this exemple i display 

  • __display_text__ = Title of item, in this case name agent
  • {{portrait##display_large}} = image field of agent (large image thumb)
  • {{skills}} = the skill field vaalue
  • {{contact}} = the contact foorm for agent

user can set linked agent 

 Now will create reverse relation to display all Estates linked to Agent

The reverse relation field is relay simple to configure because you just to need to set link between relation and relation reverse field bu i will show you how to customize display

  1. Create field "Estate in relation"
  2. Select Relation revers type
  3. Assign to Agent
  4. Select relation field "Agent"

Now we will check viewing, its the same system as relation field

Go to viewing tab

Item html

Add your light html

in this cas i use bootstrap class because style is already in protostar template

<div class="row well">
<div class="span4">
{{field15##0}}
</div>
<div class="span6">
__display_text__
</div>
<div class="span2">
{{field23##0}}
</div>

</div>

{{field15##0}} = first image of estate
__display_text__ = title of estate
{{field23##0}} = is price

...

Easy not ?

in backend you can see all Estate linked to Agent

In front end you will have a list of estate linked to Agent

  • Tags
    templating | reverse relation | relation item | field configuration
  • Categories
    Tutorial