Howto: custom publication with special fields and ad-hoc template

[email protected] (eolica) Tue, 3 Jun 2003 21:26:01 +0000 (UTC)
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization Xaraya Content Management Solutions
Message-ID <[email protected]>
How to make a new custom publication with special fields and show it with 
an ad-hoc template.

This is a small tutorial to explain the step-by-step procedures to follow.

Let say we want to make a Directory of contacts (f.i. Founding members of 
an Association). For every entry we will show the Company name, the 
Address, Tel. and Fax numbers, Website and E-mail address.

1)	As a preliminary step, using the modules Articles and Dynamicdata 
together, we need to enable hooks between them (If we have not already 
done so):
- in the Admin menu go to Global->Modules->Configure Hooks;
- Select Dynamicdata and put a mark next to Content->articles;
- Save changes.

2)	Now we need to create a new publication type.
- Again in the Admin menu, go to Content->Articles->Publication Types
- Select New and create the new type with the following fields:

Type:	contacts
Description:	Contacts

Field	Label	Format		Input	Type
title	Company	Text Box	  v	string
summary	Address	Small Text Area	  v	text
 
Leave Labels bodytext, bodyfile, notes <empty> (we don't want to use these
 fields); Leave authorid, pubdate and status unchanged;
- Create.

3)	Next step is adding custom fields.
- Again in the Admin menu, go to Content->Articles->Publication Types;
- select Article Config for your contacts type;
- At the very bottom choose [ modify ] for Dynamic Data Fields;
- A new window (I don't know why) will appear from wich you can add your 
custom fields. Add the following (one at a time):

Label	Property Type	Validation 
Tel	Text Box	0:20
Fax	Text Box	0:20
Email	E-mail		<empty>
Website	URL		<empty>

You can leave the field "Default" <empty>; Status will be Active for every
 label.
- Once you Updated Properties for the last field, close the window.

4)	Test
- Again in the Admin menu, go to Content->Dynamicdata->View Objects;
- select Edit for your new article type (name will be articles_X depending
 on how many other article types you have already);
- Choose to "Modify Dynamic Properties"; you will see your Labels and 
Property Types.

5)	Custom Template
- In your modules/articles/xartemplates directory create a file called 
user-summary-contacts.xd; this file will include some basic statements, 
plus your layout (you can do it in your preferred html editor). Where you 
want your fields you put: #$nameofthefield#

So, for our case, we will have:
#$title#
#$summary#
#$tel#
#$fax#
#$website#
#$email#

6)	Add your data
- In the Admin menu, go to Content->Articles->Add Article;
- Select the Contacts Publication Type and type ...

PS.: At the end you find my user-summary-contacts.xd, for your pleasure 
and for the Gurus critics (appreciated).
If you want to see how it will look, go to:
http://expo.eolica.tv/index.php?module=articles&func=view&ptid=7

I hope this will help

Sesto Avolio

===================<user-summary-contacts.xd >===================
<table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tr>
        <td align="left" valign="top" class="xar-normal">
            <xar:if condition="!empty($categories) and count($categories) 
gt 0">
                [ <xar:loop name="$categories">
                    #$cjoin# <a href="#$clink#">#$cname#</a>
                </xar:loop> ]
            </xar:if>
        </td>
    </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="604">
  <tr>
    <td width="502" bgcolor="#336699" style="color: rgb(226, 245, 248);"
>&nbsp;#$title#</td>
    <td width="102"></td>
  </tr>
  <tr>
    <td colspan="2">
<table border="2" width="604" cellpadding="0" cellspacing="0" bordercolor
="#336699">
  <tr>
    <td>

<table border="0" width="600" cellspacing="0" cellpadding="3">
  <tr>
    <td width="30"><img border="0" src="images/icons/icon-post.gif" alt="
Indirizzo"></td>
    <td width="100%" colspan="3">#$summary#</td>
  </tr>
  <tr>
    <td width="30"><img border="0" src="images/icons/icon-phone.gif" alt
="Telefono"></td>
    <td width="50%">#$tel#</td>
    <td width="30"><img border="0" src="images/icons/icon-fax.gif" alt="
Fax"></td>
    <td width="50%">#$fax#</td>
  </tr>
  <tr>
    <td width="30"><a href="http://#$website#" target="_blank"><img 
border="0" src="images/icons/icon-homepage.gif" alt="Visita il sito web"
></a></td>
    <td width="50%">#$website#</td>
    <td width="30"><a href="mailto:#$email#"><img border="0" src="images/
icons/icon-email.gif" alt="invia una e-mail"></a></td>
    <td width="50%">#$email#</td>
  </tr>
</table>
    </td>
  </tr>
</table>
    </td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
===================</user-summary-contacts.xd >===================