Problems, need help? Have a tip or advice? Post it here.
14 posts Page 1 of 2
Hi,

Having completed the Aurelius tutorial online I've decided to try and implement Couch on a live site.

I have a gig page and I would like to offer the client the option of adding gigs in the admin panel, much like the Add New button on cloned pages.

Here is my HTML code:

Code: Select all
<div class="gig_list_box">
               <div class="gig_date">
                   <h3>Title of Event</h3>
                    <h4>Fri 8 July, 2011</h4>
                </div><!--end gig_date-->
                <div class="gig_details">
                    <ul>
                        <li><span>Venue:</span>Some Venue</li>
                        <li><span>Time:</span>7pm</li>
                        <li><span>Tickets:</span>&pound;15</li>
                        <li class="last"><span>Info:</span><a href="#">www.google.com</a></li>
                    </ul>
                </div><!--end gig_details-->
            </div><!--end gig_list_box-->


I/my client would simply like to be able to add new gigs in the admin panel, however, I'm not sure how to do it. I can create the editable regions for each gig detail but that's where I get stuck.

Can you help?

Many thanks!

G.
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> &pound;<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> &pound;<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.
WOW!

Thanks for the detailed response; greatly appreciated!

I'll work through your recommendations and let you know how I get on.

Thanks again! :D

G.
Hi,

I've implemented your suggestions and it works. However, I only need one page for the list of gigs, meaning that I don't require a list-page view. Is there a way to do this?

Thanks in advance!

G.
Not sure if I understood it right but does that mean that whenever 'gigs.php' (or whatever you named the template) is accessed, it always shows a listing of the gigs?
If that is the case, you do not require the 'page view'.

Simply remove the 'if k_is_page' logic and just use the 'pages' tag to create a listing. Since we are not checking for the view we are in, ALL views will display this listing.
Follow the Aurelius tutorial to code the listing, please.
Hi,

Yes, you're right, and thank you for helping me with this!

You must get tired of me asking simple questions (I know there will be many more until I come up to speed with Couch)!

Thanks for the great support; I'm really enjoying Couch!

G.
Not a problem at all :)
You are most welcome. Please feel free to ask about anything that seems problematic to you.
Hi,

Regarding your proposed solution above, I have a question regarding the 'date' field. I want to be able to add gig dates that are in the future so I believe that the 'publish date' field will not work for this. I have set up a normal 'text' field to accommodate the 'date' and this works fine. However, I now wish to order the list of gigs by their 'gig date' and this is where I'm having problems; I can't seem to get the list to output in the correct order.

Can you help?

Many thanks,

G.
..I want to be able to add gig dates that are in the future so I believe that the 'publish date' field will not work for this..

There is no problem in using publish_date with future dates.
I think what must be stumping you is that the 'cms:pages' tag ignores future entries. Right?
To make 'cms:pages' tag display future entries too, simply set its 'show_future_entries' parameter to '1' -
Code: Select all
<cms:pages masterpage='gigs_list.php' show_future_entries='1'>
   ...
</cms:pages>

You can use a normal text field for dates too but for your current purpose the built-in system field is more suitable. Please make the changes and let me know.

Thanks
Fantastic! This works a treat!

I'm so grateful for your time and effort in aswering my questions!

Many thanks,

G.
14 posts Page 1 of 2

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests