Relationships between Content Models

From GruppoZenit
Jump to: navigation, search

Relationships between Content Models are defined during their creation itself with the help of attributes having data type "lookup".


This favours proper inputting and storing of content data for attributes of respective Content Models. Now, to present such relationships in webpages, Z-CMS provides the following Z-CMS relation tags: zcms:lookup-content and zcms:content-relation.


The relation tag zcms:lookup-content is used to establish a lookup relation from one Content Model to another Content Model. The relation tag zcms:content-relation is used to specify the lookup criterion. A sample usage of these relation tags is given below:

<zcms:lookup-content name="user" join="inner" alias="USER">
<zcms:content-relation content-attribute="user_id" lookup-attribute="user_id" joinwith="AND"/>


Example: building a relation between Content Models

Consider the following case which establishes a lookup relation from "web-menu" (Content Model which represents certain Menu Entries having attributes like menu_id, sort_order, etc.) to "web-menu-lang" (Content Model which represents certain Menu Entry characteristics per certain languages like menu_name, lang_code (language code), an image, etc.):

<zcms:content name="web_menu" id="fourthLevel" alias="webmenu3" standalone="true"> 
   <zcms:lookup-content name="web_menu_lang" join="inner" alias="WML"> 
      <zcms:content-relation content-attribute="menu_id" lookup-attribute="menu_id" joinwith="AND"/> 	
      <zcms:content-relation lookup-attribute="lang_code" value="$request[language]" />
   </zcms:lookup-content>
   <zcms:dataorder attribute="sort_order" order="asc"/>
      <a href="[zcms:attribute:page_url]" class="serv_int_box"> 
         <div class="fr_link"><img src="images/fr_link_box.png" width="31" height="31" /></div> 
         <img class="image" src="[zcms:attribute:image1]" width="260" height="130" />
         <p class="box_title"><zcms:attribute name="menu_name" /></p>
      </a>
   <zcms:filter value="$result[*parent, menu_id]" attribute="menu_id" />
</zcms:content>

In this example, "web_menu.menu_id" is the content attribute and "web_menu_lang.menu_id" is the lookup attribute. Here, "sort_order" is an attribute belonging to "web_menu" while "menu_name" is an attribute belonging to "web_menu_lang". Further, "menu_name" can also be accessed specifically using the alias specified for the Content Model it belongs to as follows:

<zcms:datacolumn name="menu_name" alias="WML" />

Also, in this example, an "AND" condition is joined with the "INNER JOIN" (web_menu-web_menu_lang) to specify "web_menu_lang.lang_code", whose value is obtained from page request.


Relationships visualization types

Relationships between Content Models are always created by using the "lookup" Attribute.


However in Z-CMS there is the possibility to use some visualitation tools that allow the user to deal with related Content Models in an easier way. Such tools are the following:

  • Collections: when two Content Models are related one to the other it may be difficult for the user to add contents inside them if he is not able to visualize them in the same page inside the CMS. By means of a collection the user can view more than one Content Model inside the same page.
  • Bridges: when a Content Model has more than one lookup relation with other Content Models (for example a "News" Content Model that can be related with more different "News_category" Content Models) it may be useful to show the list of lookup Content Models inside the page of the main Content Model. In that case the user can select the preferred relation while adding contents to the Content Model by simply clicking on a multiple choice panel with all possible relations.
  • Hierarchies: when there are lists of Content Models on different hierarchical levels (for example a relation between a product inside a series of product categories in which one is a sub-sample of the other, like "black_shoe_product" inside growing categories "new_models", "male_shoes", "winter_collection") it is possible to create a hierarchy of Content Models that facilitate the user in defining the relations that occurs between such Content Models.


See also

Personal tools
Namespaces

Variants
Actions
Toolbox