10 - Creation relation field to link Agent and Estate
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
- Create a field and set Agent
- Select REaltion type
- Assign to Estate content
In Editing type you will allow to link Estate only with Agent
- Editing tab
- Category selector
- Select your category
After we can configure displaying, basicly relation display only title and link, explain that we can do more
- Go to viewing tab
- Related items list
- 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
- Create field "Estate in relation"
- Select Relation revers type
- Assign to Agent
- 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