Difference between revisions of "Using Related Items"

From ActionApps Documentation
Jump to: navigation, search
(Categories based on related items)
(From long item id to a readable label)
Line 1: Line 1:
 
== From long item id to a readable label ==  
 
== From long item id to a readable label ==  
<div class="aafaq" id="faq1736"><aafaq id=1736> ~ToDo: id=1736 How can I use the related items feature to link items from one slice into another rel:2051,</aafaq>
 
==== FAQ: How can I use the related items feature to link items from one slice into another ====
 
  
 +
=== FAQ: How can I use the related items feature to link items from one slice into another ===
 +
<div class="aafaq" id="faq1736"><aafck id=1736> ~ToDo: id=1736 How can I use the related items feature to link items from one slice into another rel:2051,</aafck>
  
 
** Input (setting the admin interface)
 
** Input (setting the admin interface)
Line 9: Line 9:
 
<li>add new field to the slice, where you want to store related item</li>
 
<li>add new field to the slice, where you want to store related item</li>
 
<li>go to Edit page for the new field (Admin - Fields - Edit)</li>
 
<li>go to Edit page for the new field (Admin - Fields - Edit)</li>
<li>choose one of the following options in 'Input type' selectbox:<br />
+
<li>choose one of the following options in 'Input type' selectbox:
- Related Item Window<br />
+
- Related Item Window
- Multiple SelectBox<br />
+
- Multiple SelectBox
- Select box<br />
+
- Select box
- Check box<br />
+
- Check box
- Multiple Checkboxes<br />
+
- Multiple Checkboxes
- RadioButton<br />
+
- RadioButton
 
(this is sorted in order of usability - most useful is 'Related Item Window'
 
(this is sorted in order of usability - most useful is 'Related Item Window'
 
or Selectbox)  </li>
 
or Selectbox)  </li>
Line 23: Line 23:
 
<li>click on 'Update' - Input is set</li>
 
<li>click on 'Update' - Input is set</li>
 
</ol>
 
</ol>
<br />One Note on 'Related Item Window' - in fact it is the only one option to use
+
One Note on 'Related Item Window' - in fact it is the only one option to use
 
if you want to use the field as 'Related Item' because other options shows all
 
if you want to use the field as 'Related Item' because other options shows all
 
slice items on one page, which is usually too much. Another feature of 'Related
 
slice items on one page, which is usually too much. Another feature of 'Related
Line 29: Line 29:
 
but you can add '2 way relation' between items - written item (say 2) is not
 
but you can add '2 way relation' between items - written item (say 2) is not
 
only related to assigned item 1, but the item 1 is then related to item 2 then.
 
only related to assigned item 1, but the item 1 is then related to item 2 then.
<br />The next problem is, how to display the related items on webpage.
+
The next problem is, how to display the related items on webpage.
<br />** Output (1) - Standard use of views
+
** Output (1) - Standard use of views
 
<ol>
 
<ol>
 
<li>go to Admin - Design Views page</li>
 
<li>go to Admin - Design Views page</li>
Line 37: Line 37:
 
one item in view)</li>
 
one item in view)</li>
 
<li>Fill the name of view, Top, Bottom and Odd row HTML code (the condition
 
<li>Fill the name of view, Top, Bottom and Odd row HTML code (the condition
fields you can leave blank)<br />
+
fields you can leave blank)
For example: <br />
+
For example:  
Item listing: Item List - related test<br />
+
Item listing: Item List - related test
 
Odd Rows: <br>Related: How can I use the related items feature to link items from one slice into another</li>
 
Odd Rows: <br>Related: How can I use the related items feature to link items from one slice into another</li>
 
<li>Click on 'Update'</li>
 
<li>Click on 'Update'</li>
<li>Create page which includes the view. Say the view number is 110:<br />
+
<li>Create page which includes the view. Say the view number is 110:
related.shtml<br />
+
related.shtml
 
APC - ActionApps Test Site</li>
 
APC - ActionApps Test Site</li>
 
<li>go to Admin - Fields - Related field Edit page</li>
 
<li>go to Admin - Fields - Related field Edit page</li>
<li>create an alias for the Related field:<br />
+
<li>create an alias for the Related field:
Alias 1: _#RELATED_ (the name is up to you)<br />
+
Alias 1: _#RELATED_ (the name is up to you)
Function: f_h<br />
+
Function: f_h
Parameters: - <br />
+
Parameters: -  
 
(the parameter is DASH - used as separator for multiple item ids)</li>
 
(the parameter is DASH - used as separator for multiple item ids)</li>
 
<li>go to 'Admin - Design Index' page</li>
 
<li>go to 'Admin - Design Index' page</li>
<li>Add next code to 'Odd rows' field:<br />
+
<li>Add next code to 'Odd rows' field:
 
<a href="related.shtml?cmd[110]=i-110-_#RELATED_">Related</a></li>
 
<a href="related.shtml?cmd[110]=i-110-_#RELATED_">Related</a></li>
<li>click Update - link to related stories Done<br />
+
<li>click Update - link to related stories Done
 
</li>
 
</li>
 
</ol>
 
</ol>
<br />This is the way, how to create link to related item view and also this is the
+
This is the way, how to create link to related item view and also this is the
 
way, how to create link to fulltext view  
 
way, how to create link to fulltext view  
<br />For related item however we expected another behavior. We want to display related
+
For related item however we expected another behavior. We want to display related
 
items under the fulltext of the item (or directly under each item on index page).
 
items under the fulltext of the item (or directly under each item on index page).
 
That's why we introduced 'view as alias feature':
 
That's why we introduced 'view as alias feature':
<br />** Output (2) - view as alias
+
** Output (2) - view as alias
<br />steps 1) - 4) is exactly the same as in Output (1)
+
steps 1) - 4) is exactly the same as in Output (1)
 
<ol start="5">
 
<ol start="5">
 
<li>go to Admin - Fields - Related field Edit page</li>
 
<li>go to Admin - Fields - Related field Edit page</li>
<li>create an alias for the Related field:<br />
+
<li>create an alias for the Related field:
Alias 2: _#SHOWVIEW (the name is up to you)<br />
+
Alias 2: _#SHOWVIEW (the name is up to you)
Function: f_v <br />
+
Function: f_v  
Parameters: vid=110&cmd[110]=i-110-_#this<br />
+
Parameters: vid=110&cmd[110]=i-110-_#this
 
As the parameter we write the same parameters we would write for view.php3
 
As the parameter we write the same parameters we would write for view.php3
 
as url parameters. The only difference is, that we use the keyword _#this,
 
as url parameters. The only difference is, that we use the keyword _#this,
which is substituted by item ids from the field. <br />
+
which is substituted by item ids from the field.  
 
Note: _#this is not alias - is is not defined as other aliases, it is much
 
Note: _#this is not alias - is is not defined as other aliases, it is much
 
more the keyword - see <a href="http://actionapps.org/faq/detail.shtml?x=1674">Paramater substitution in f_v</a></li>
 
more the keyword - see <a href="http://actionapps.org/faq/detail.shtml?x=1674">Paramater substitution in f_v</a></li>
 
<li>go to 'Admin - Design Fulltext' page (for example)</li>
 
<li>go to 'Admin - Design Fulltext' page (for example)</li>
<li>Add next code to 'Fulltext HTML code' field:<br />
+
<li>Add next code to 'Fulltext HTML code' field:
 
<br>Related: _#SHOWVIEW</li>
 
<br>Related: _#SHOWVIEW</li>
 
<li>click Update - related items displayed</li>
 
<li>click Update - related items displayed</li>
 
</ol>
 
</ol>
<br />Output (2) describes how to create view alias. With such alias you can work
+
Output (2) describes how to create view alias. With such alias you can work
 
as with any other aliases.
 
as with any other aliases.
<br />Tip: <br />
+
Tip:  
 
In step 6) of Output (2) we used field content as list of displayed items:
 
In step 6) of Output (2) we used field content as list of displayed items:
<p class="code">vid=110&cmd[110]=i-110-_#this  
+
vid=110&cmd[110]=i-110-_#this  
<br />In some cases we may want to switch between the views depending on field content.
+
In some cases we may want to switch between the views depending on field content.
 
Then you can use parameter like:
 
Then you can use parameter like:
<p class="code">vid=110&cmd[110]=v-_#this  
+
vid=110&cmd[110]=v-_#this  
 
or more complicated:
 
or more complicated:
<p class="code">vid=110&cmd[110]=i-_#unspecified.....-_#this
+
vid=110&cmd[110]=i-_#unspecified.....-_#this
<br />Then the fields <this> in example a) or unspecified..... in example b)
+
Then the fields <this> in example a) or unspecified..... in example b) should contain the ids of view to show (112, 113...).
should contain the ids of view to show (112, 113...).
 
<br /><b>How do I create a View which indexes all items that relate to that item.</b>
 
<br />An example might help..
 
<br /> I have two slices 'authors' and 'articles'.<br />
 
  
<br />In articles I have a field 'author' which relates to the slice 'authors' (in
+
<b>How do I create a View which indexes all items that relate to that item.</b>
it is stored ID or IDs of author/authors of the article).<br />
+
An example might help..
 +
I have two slices 'authors' and 'articles'.
  
<br />So in articles on the web is displayed information from the 'authors' slice.<br />
+
In articles I have a field 'author' which relates to the slice 'authors' (in
<br />
+
it is stored ID or IDs of author/authors of the article).
But now I would like to show references to articles on the pages of their authors.
+
 
And I don't want to make it by a new relation field in the slice 'articles',
+
So in articles on the web is displayed information from the 'authors' slice.
because I would have to after addition of a new article go to the slice 'authors'
+
 
and edit the author's profile - make a relation to the new article.
+
But now I would like to show references to articles on the pages of their authors. And I don't want to make it by a new relation field in the slice 'articles',
<br />Do you have some idea, how to display the information from the slice 'articles'
+
because I would have to after addition of a new article go to the slice 'authors' and edit the author's profile - make a relation to the new article.
in the slice 'authors' if the relation field is in the slice 'articles'?<br />
+
Do you have some idea, how to display the information from the slice 'articles' in the slice 'authors' if the relation field is in the slice 'articles'?
<br />
+
 
Yes, it should be possible to display author's articles, because there is the
+
Yes, it should be possible to display author's articles, because there is the "relation" field for Author (the created_by.....1 in your case) in
"relation" field for Author (the created_by.....1 in your case) in
+
the Article slice. There are the ids of 'Author' records (items) stored in this field. So, it is possible to create view (say number 123) in 'Article' slice
the Article slice. There are the ids of 'Author' records (items) stored in this
+
where the first condition will be  
field. So, it is possible to create view (say number 123) in 'Article' slice
+
Author =
where the first condition will be
+
Then, you just create the page which includes the view:
<p class="code">Author =
+
 
<br />Then, you just create the page which includes the view:<br />
+
---author.shtml ---
 +
&lt;!--#include virtual="/aaa/view.php3?vid=123"--&gt;
  
<br /><span class="code">---author.shtml ---<br />
 
<!--#include virtual="/aaa/view.php3?vid=123"--><br />
 
</span><br />
 
 
The link to this page then should look like:
 
The link to this page then should look like:
<p class="code">author.shtml?cmd[123]=c-1-5254422456eab4763bea34
+
author.shtml?cmd[123]=c-1-5254422456eab4763bea34
<br />where 5254422456eab4763bea34is item (=author) id in Author slice. Such link
+
where 5254422456eab4763bea34is item (=author) id in Author slice. Such link can be generated automaticaly Index - Odd row (for example):
can be generated automaticaly Index - Odd row (for example):
 
<p class="code"><a href="author.shtml?cmd[123]=c-1-4f35cd6ab328690caffbe7d646eded78">_#NAME####</a>
 
 
 
  
 +
&lt;a href="author.shtml?cmd[123]=c-1-4f35cd6ab328690caffbe7d646eded78"&gt;_#NAME####&lt;/a&gt;
  
 
</div>
 
</div>

Revision as of 21:21, 2 September 2005

From long item id to a readable label

FAQ: How can I use the related items feature to link items from one slice into another

Origin: ~ToDo: id=1736 How can I use the related items feature to link items from one slice into another rel:2051,
    • Input (setting the admin interface)
  1. go to Admin - Fields
  2. add new field to the slice, where you want to store related item
  3. go to Edit page for the new field (Admin - Fields - Edit)
  4. choose one of the following options in 'Input type' selectbox: - Related Item Window - Multiple SelectBox - Select box - Check box - Multiple Checkboxes - RadioButton (this is sorted in order of usability - most useful is 'Related Item Window' or Selectbox)
  5. If you choose 'Related Item Window' then in the Constant field you can select not only the constants groups, but you can select there also the slice! If you select there the slice, there will be item headlines as options in the inputform. It allows you to select related items for the one you are writing. As you see it is possible to select any slice in here, so it is possible to create related items not only from the current slice, but to another slice too. It is possible to have the slice of items and another slice of authors and then set the relation through such field. For related item just select there the same slice you are in.
  6. Select the 'Item IDs' option in Insert field to be the related items ids correctly written to database.
  7. click on 'Update' - Input is set

One Note on 'Related Item Window' - in fact it is the only one option to use if you want to use the field as 'Related Item' because other options shows all slice items on one page, which is usually too much. Another feature of 'Related Item Window' is, that it is possible to add items not only to the written item, but you can add '2 way relation' between items - written item (say 2) is not only related to assigned item 1, but the item 1 is then related to item 2 then. The next problem is, how to display the related items on webpage.

    • Output (1) - Standard use of views
  1. go to Admin - Design Views page
  2. create new view (you can create the 'Fulltext view' if you want to show only one item or you can create 'Item listing' view for displaying more than one item in view)
  3. Fill the name of view, Top, Bottom and Odd row HTML code (the condition fields you can leave blank) For example: Item listing: Item List - related test Odd Rows:
    Related: How can I use the related items feature to link items from one slice into another
  4. Click on 'Update'
  5. Create page which includes the view. Say the view number is 110: related.shtml APC - ActionApps Test Site
  6. go to Admin - Fields - Related field Edit page
  7. create an alias for the Related field: Alias 1: _#RELATED_ (the name is up to you) Function: f_h Parameters: - (the parameter is DASH - used as separator for multiple item ids)
  8. go to 'Admin - Design Index' page
  9. Add next code to 'Odd rows' field: <a href="related.shtml?cmd[110]=i-110-_#RELATED_">Related</a>
  10. click Update - link to related stories Done

This is the way, how to create link to related item view and also this is the way, how to create link to fulltext view For related item however we expected another behavior. We want to display related items under the fulltext of the item (or directly under each item on index page). That's why we introduced 'view as alias feature':

    • Output (2) - view as alias

steps 1) - 4) is exactly the same as in Output (1)

  1. go to Admin - Fields - Related field Edit page
  2. create an alias for the Related field: Alias 2: _#SHOWVIEW (the name is up to you) Function: f_v Parameters: vid=110&cmd[110]=i-110-_#this As the parameter we write the same parameters we would write for view.php3 as url parameters. The only difference is, that we use the keyword _#this, which is substituted by item ids from the field. Note: _#this is not alias - is is not defined as other aliases, it is much more the keyword - see <a href="http://actionapps.org/faq/detail.shtml?x=1674">Paramater substitution in f_v</a>
  3. go to 'Admin - Design Fulltext' page (for example)
  4. Add next code to 'Fulltext HTML code' field:
    Related: _#SHOWVIEW
  5. click Update - related items displayed

Output (2) describes how to create view alias. With such alias you can work as with any other aliases. Tip: In step 6) of Output (2) we used field content as list of displayed items:

vid=110&cmd[110]=i-110-_#this 

In some cases we may want to switch between the views depending on field content. Then you can use parameter like:

vid=110&cmd[110]=v-_#this 

or more complicated:

vid=110&cmd[110]=i-_#unspecified.....-_#this

Then the fields <this> in example a) or unspecified..... in example b) should contain the ids of view to show (112, 113...).

How do I create a View which indexes all items that relate to that item. An example might help..

I have two slices 'authors' and 'articles'.

In articles I have a field 'author' which relates to the slice 'authors' (in it is stored ID or IDs of author/authors of the article).

So in articles on the web is displayed information from the 'authors' slice.

But now I would like to show references to articles on the pages of their authors. And I don't want to make it by a new relation field in the slice 'articles', because I would have to after addition of a new article go to the slice 'authors' and edit the author's profile - make a relation to the new article. Do you have some idea, how to display the information from the slice 'articles' in the slice 'authors' if the relation field is in the slice 'articles'?

Yes, it should be possible to display author's articles, because there is the "relation" field for Author (the created_by.....1 in your case) in the Article slice. There are the ids of 'Author' records (items) stored in this field. So, it is possible to create view (say number 123) in 'Article' slice where the first condition will be

Author =

Then, you just create the page which includes the view:

---author.shtml ---
<!--#include virtual="/aaa/view.php3?vid=123"-->

The link to this page then should look like:

author.shtml?cmd[123]=c-1-5254422456eab4763bea34

where 5254422456eab4763bea34is item (=author) id in Author slice. Such link can be generated automaticaly Index - Odd row (for example):

<a href="author.shtml?cmd[123]=c-1-4f35cd6ab328690caffbe7d646eded78">_#NAME####</a>

Categories based on related items

How do I customise the Category breaks in an index view from another slice

Origin: ~ToDo: id=1725 How do I customise the Category breaks in an index view from another slice

This requires relating items in the first slice to the second, and using a related view.

  • Create a slice, called for example Yyyy where your categories will be stored.
  • Admin->Views->Full Text->New:
  • Edit this view as you wish, for example it could include the _#FULLTEXT alias which could contain text about the category. This will appear above each group of categories, (assume this is view 99)
  • Create the slice where the data will be stored
  • Admin->Fields->Category->Edit
  • Input = Check box, Selected from Yyyy
  • Create alias _#VIEW_CAT with paramater "vid=99&cmd[99]=x-99-_#this
  • The _#this will be substituted by the short item id of the item related, in this case the one from Yyyy
  • Admin->Index
  • Set "Sort Items by Category"
  • Category Headline = _#VIEW_CAT (plus any other HTML wanted)