Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
Custom fields for events?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic     Forum Index -> Hacking Thyme
View previous topic :: View next topic  
Author Message
Kent
Guest





PostPosted: Thu Jan 19, 2006 6:04 pm    Post subject: Custom fields for events? Reply with quote

I'm wondering how I can add custom fields for the events.

Thanks,

Kent
Back to top
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Thu Jan 19, 2006 7:14 pm    Post subject: Reply with quote

Hi Kent,

This will require some PHP knowledge. You may add custom fields to events by:

Let's say the field is called Price.

1) Adding the field to the Events table. You may do this through any SQL server admin program. MyPHPAdmin etc.. Create a field in the table called Price.

2) Adding the field to include/templates/event_edit_tpl.php. Add a text box to the form where users may enter a price. Make sure to name the text box 'Price'. You can do this by adding something like:

$_cal_tmpl->section_row("Price", $_cal_form->textbox('Price'));

3) Adding Price to include/templates/event_view_tpl.php. You could do something like:

$_cal_tmpl->section_row("Price", $_cal_event->Price);

Don't hesitate to ask any questions if you have them.
Back to top
View user's profile Send private message Visit poster's website
Kent
Guest





PostPosted: Thu Jan 19, 2006 10:16 pm    Post subject: Reply with quote

I'm amazed at your response time to answer these questions.

Thank-you very much! And I think I forgot to say thank-you for your solution to my previous question. It was just what I needed.

Kent
Back to top
Phil
Guest





PostPosted: Mon Jan 23, 2006 7:37 pm    Post subject: Reply with quote

Hi,

Related to this, is it possible to then retrieve the new field data using Thyme's API (eg using something like

$e->price

or would I need to re-query the database to retrieve this?

Thanks
Phil
Back to top
patrick



Joined: 10 Sep 2005
Posts: 70

PostPosted: Mon Jan 23, 2006 7:45 pm    Post subject: Reply with quote

Everything that is a field in the Events table is available as $e->field. If you added Price, it would be available as $e->Price. No separate query is needed.

Though it's not exactly point-and-click yet, we've tried to make it as easy as possible for someone with a little PHP experience to be able to add a field.
Back to top
View user's profile Send private message
Phil
Guest





PostPosted: Tue Jan 24, 2006 2:54 pm    Post subject: Reply with quote

Thanks Patrick, that makes life a lot easier...

I do think you've done a great job with this - well done.

Phil
Back to top
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Wed Jul 05, 2006 4:36 am    Post subject: Reply with quote

Hi, i will need to add several custom fields...i think i could do with adding them to the events table as explained before on this post.

But for my specific needs, some of those new fields will be applicable to a certain category only and so on, so lets's say i have categories "Category1", "Category2" and "Category3". I would add custom fields to events table: "custom1", "custom2", "custom3", "custom5", "custom6" and "custom8".

I need that when a user adds/requests an event, some of those custom fields are shown depending on the category selected.

For example if "Category1" is selected custom fields "custom1" and "custom2" would be available in the form. If the user selects "Category2" then the custom fields applicable before, would be hidden and "custom3" and "custom3" would be shown...

Of course an equivalent behaviour would need to take place when modifying an event.

Any hints on how to do this?

Many thanks...
Cheers,
NiCo Smile
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Jul 05, 2006 11:19 am    Post subject: Reply with quote

Something like this:

Code:
$_cal_tmpl->new_row();

echo("<span id='opt1span' style='display: hidden'>")
echo($_cal_form->checkbox('opt1') .' Option 1');
echo("</span>");

.. more spans with options ..

$_cal_tmpl->end_row();


.. modify the category select box and add a 3rd agument:

Code:
$_cal_form->select("type", array('('._NONE_.')') + $_cal_event->cal_etypes,
 " onChange='upd_opts()'")


.. add a javascript function to handle this:

Code:


function upd_opts() {

   var catsel = document.EventForm.elements['type'].selectedIndex;

    if(catsel == 1) {
       document.getElementById('opt1span').style.display = 'inline';
       document.getElementById('opt2span').style.display = 'none';
   } else ..

}

}
Back to top
View user's profile Send private message Visit poster's website
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Wed Jul 05, 2006 5:53 pm    Post subject: Reply with quote

Sorry,

but that first piece of code in your last message, in what file must it go?

If it is in /include//templates/event_edit_tpl.php does it mean that it goes instead of $_cal_tmpl->section_row("Price", $_cal_form->textbox('Price')); ?

So i would add as you mentioned:

$_cal_tmpl->new_row();

echo("")
echo($_cal_form->textbox('Price') .'Price: ');
echo("");

$_cal_tmpl->end_row();

And then i would add all my other custom fields in the same manner between that new_row() and end_row()?

Cheers,
NiCo Wink
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Jul 05, 2006 5:56 pm    Post subject: Reply with quote

Yep
Back to top
View user's profile Send private message Visit poster's website
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Wed Jul 05, 2006 10:27 pm    Post subject: Reply with quote

Cool...

I am working on that now Very Happy

how do i set any of those custom checkboxes to be "checked" by default?

Also... how can i have the labels bold? The reson why i ask is because If i would have done $_cal_tmpl->section_row("Price: ", $_cal_form->textbox('Price')); then the label "Price: " would have been bold and the label and the textbox, alligned with the standard fields, but if i put that inside a span and between new_row()/end_row() then the label is not bold and the aligment is completely to the left.

Cheers,
NiCo
Back to top
View user's profile Send private message
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Wed Jul 05, 2006 10:53 pm    Post subject: Reply with quote

Hi,

Defaults:

Do: $form->defaults['opt1'] = 1;

before you print the form element.

Bold:

Wrap the label around <b> </b> tags.
Back to top
View user's profile Send private message Visit poster's website
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Thu Jul 13, 2006 2:58 am    Post subject: Reply with quote

In case somebody goes through this to add custom fields that show depending on the event category chosen, there is a small error in part of the code mentioned in this thread:

ian wrote:


Code:


function upd_opts() {

   var catsel = document.EventForm.elements['type'].selectedIndex;

    if(catsel == 1) {
       document.getElementById('opt1span').style.display = 'inline';
       document.getElementById('opt2span').style.display = 'none';
   } else ..

}

}


in that function, .value should be used instead of .selectedIndex

Cheers,
NiCo Wink
Back to top
View user's profile Send private message
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Fri Jul 14, 2006 2:57 am    Post subject: Reply with quote

Hi...

I was wondering if there is a way that i can define that a textbox will only allow numeric data to be entered(actually numbers with decimal too). I don't want the user to be able to type letters.

Or is it the only option to do it when validating the data in the Onsubmit part?

Cheers,
NiCo
Back to top
View user's profile Send private message
smeallum



Joined: 17 May 2006
Posts: 177

PostPosted: Thu Jul 20, 2006 6:04 am    Post subject: Reply with quote

i just need to know, since there might be a class property specifically for that. Or do i just ned to work it on the Onsubmit part?

Cheers,
NiCo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Hacking Thyme All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.