by
KK » Fri Jul 15, 2011 5:38 am
Hi,
Taking the HTML code you posted as guide, the following pieces of information constitute a
single gig -
Title
Date
Venue
Time
Ticket Amount
Info
We can use a template named 'gig.php' and create editable regions in it to capture each of the items listed above.
The template can be declared 'clonable' and this way we can create as many gig items as we wish.
Before creating the editable regions, let us decide which type of editable region will be suited for each of the items.
Title - Every cloned page already has a title field. We can use this hence no need to create a custom field for this.
Date - Similar to the title field above, each cloned page already has a 'publish date' field. So no need to create a custom field for this too.
Venue - This looks like info that can be entered in a single line of text. We can create an editable region of type 'text' for this (if info that will span more than one line is anticipated, use type 'textarea' instead).
Time We can use a dropdown pre-populated with valid time values (increments of half-hour should suffice).
Ticket Amount We can use a 'text' type to capture this info. We can use the 'search_type' and 'validator' parameters to ensure that only numeric (non negative decimal) values are entered in this field.
Info A 'richtext' type seems to be the obvious choice here.
Following is the code that can be placed in the 'gig.php' template to create the editable regions we decided upon above -
- Code: Select all
<cms:template title='Gig' clonable='1'>
<cms:editable name='venue' label='Venue' type='text' />
<cms:editable name='time' label='Time (24 Hrs)'
opt_values='
00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30 | 11:00 | 11:30 |
12:00 | 12:30 | 13:00 | 13:30 | 14:00 | 14:30 | 15:00 | 15:30 |
16:00 | 16:30 | 17:00 | 17:30 | 18:00 | 18:30 | 19:00 | 19:30 |
20:00 | 20:30 | 21:00 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
type='dropdown' />
<cms:editable name='amount' label='Amount' desc='Amount in USD (correct upto 2 decimal points)'
search_type='decimal'
validator='non_negative_decimal'
type="text" >0</cms:editable>
<cms:editable name='info' label='Info' type='richtext' />
</cms:template>
With the editable regions created, it is a simple task to place the variables within the HTML code you posted. The modified HTML now becomes -
- Code: Select all
<div class="gig_list_box">
<div class="gig_date">
<h3><cms:show k_page_title /></h3>
<h4><cms:date k_page_date format='D j F, Y' /></h4>
</div><!--end gig_date-->
<div class="gig_details">
<ul>
<li><span>Venue:</span> <cms:show venue /></li>
<li><span>Time:</span> <cms:show time /></li>
<li><span>Tickets:</span> £<cms:show amount /></li>
<li class="last"><span>Info:</span> <cms:show info /></li>
</ul>
</div><!--end gig_details-->
</div><!--end gig_list_box-->
Of course, since the template is clonable, the variables will contain values only in 'page view'.
We can add the logic for the 'page view' and 'list view' as follows -
- Code: Select all
<cms:if k_is_page >
<div class="gig_list_box">
<div class="gig_date">
<h3><cms:show k_page_title /></h3>
<h4><cms:date k_page_date format='D j F, Y' /></h4>
</div><!--end gig_date-->
<div class="gig_details">
<ul>
<li><span>Venue:</span> <cms:show venue /></li>
<li><span>Time:</span> <cms:show time /></li>
<li><span>Tickets:</span> £<cms:show amount /></li>
<li class="last"><span>Info:</span> <cms:show info /></li>
</ul>
</div><!--end gig_details-->
</div><!--end gig_list_box-->
<cms:else />
.. handle list view here by using the 'pages' tag ..
</cms:if>
I trust you'll be able to code the listing in 'list view' by using the Aurelius tutorial.
Hope this helps.