Jump to content

Calendar Template System


HeadStand

Recommended Posts

Calendar Template System


The Calendar Template System allows you to customize your calendars and create forms for the user to fill out when posting a new event. [*]Create custom fields - supported field types include text, text area, checkbox, radio button, dropdown, multi-checkbox, and multi-select [*]Mark individual fields as required - members cannot start a topic unless required fields are populated [*]Add field validation - numeric, date, email, and URL [*]Group custom fields into Templates for individual calendars [*]Customize template views for the Post Screen, Event View, and Calendar View [*]Allow members of specific groups to enter HTML and/or BBCode in custom fields [*]Allow multiple templates per calendar to give users a choice of how events should be created
Field values are stored with the event content and are therefore included in any Search.

This version has been tested for 3.4 compatibility.

 

For the IPS4 version of this application, see  https://invisionpower.com/files/file/8200-template-system/.


 

Link to comment
Share on other sites

  • Replies 121
  • Created
  • Last Reply

Would you know how someone could display the additional fields we create with this mod, inside IP.Content?

So if I have an IP.Content block (feed/plugin) that shows Upcoming Events, would it be possible to also fetch something like "$event_customfield_id" to show a custom field I added to the calendar template (which might be something like "Entry Price") ???

Link to comment
Share on other sites


Would you know how someone could display the additional fields we create with this mod, inside IP.Content?



So if I have an IP.Content block (feed/plugin) that shows Upcoming Events, would it be possible to also fetch something like "$event_customfield_id" to show a custom field I added to the calendar template (which might be something like "Entry Price") ???



.... my question as well... but from what i am reading above, seems it is part of the event content field.
Link to comment
Share on other sites

Well in my database, in the "cal_events" table the "event_content" field has this as it's contents:


<!-- CALENDAR TEMPLATE FIELDS -->Game Server: gs1.domain.com<br><!-- CALENDAR TEMPLATE FIELDS -->

So, no the fields aren't stored in there. There is also a field though called "template_fields" which I guess was added after installing this mod. It has the contents I think I'm after, but it's confusing:


a:1:{i:0;a:2:{s:8:"field_id";s:1:"1";s:11:"field_value";s:15:"gs1.domain.com";}}

All of that was done using a new template with a single custom field. post-202568-0-75775400-1327395315_thumb. post-202568-0-85894600-1327395367.jpg After adding a second custom field to the template, the "template_fields" contents looks like this:


a:2:{i:0;a:2:{s:8:"field_id";s:1:"1";s:11:"field_value";s:14:"gs1.domain.com";}i:1;a:2:{s:8:"field_id";s:1:"2";s:11:"field_value";s:13:"ts.domain.com";}}



So I'm thinking in IP.Content it has to be told to look inside the "template_fields" table, but skip most of the comma seperated values until it gets to the value you want. Still confusing, but at least all these custom fields are inside the cal_events table, unlike RSVP's which have it's own tables which I guess is why none of the IP.Content blocks can pull data from it :(

Link to comment
Share on other sites


Well in my database, in the "cal_events" table the "event_content" field has this as it's contents:



<!-- CALENDAR TEMPLATE FIELDS -->Game Server: gs1.domain.com<br><!-- CALENDAR TEMPLATE FIELDS -->

So, no the fields aren't stored in there. There is also a field though called "template_fields" which I guess was added after installing this mod. It has the contents I think I'm after, but it's confusing:


a:1:{i:0;a:2:{s:8:"field_id";s:1:"1";s:11:"field_value";s:15:"gs1.domain.com";}}

All of that was done using a new template with a single custom field. post-202568-0-75775400-1327395315_thumb. post-202568-0-85894600-1327395367.jpg After adding a second custom field to the template, the "template_fields" contents looks like this:


a:2:{i:0;a:2:{s:8:"field_id";s:1:"1";s:11:"field_value";s:14:"gs1.domain.com";}i:1;a:2:{s:8:"field_id";s:1:"2";s:11:"field_value";s:13:"ts.domain.com";}}



So I'm thinking in IP.Content it has to be told to look inside the "template_fields" table, but skip most of the comma seperated values until it gets to the value you want. Still confusing, but at least all these custom fields are inside the cal_events table, unlike RSVP's which have it's own tables which I guess is why none of the IP.Content blocks can pull data from it :sad:


http://us.php.net/ma...unserialize.php
its being stored as a serialized array you can unserialize and loop through to show conditionally then.
Link to comment
Share on other sites

Don't even try parsing the contents of template_fields.... it won't give you nearly enough info to display anything properly.

The majority of the "work" done by this app is handled by a single class. This class is designed so that you should be able to pull the info you need - you tell it which calendar/event you're looking at, and it does everything for you.

Can you please tell me exactly what you'd like to do? Do you want to show ALL the fields in, say, the "Event Display View"? Or is it just one or two specific fields? Give me a little more detail, and I'll provide you with the code.... it will probably amount to 5-6 lines, you should be able to create a Custom PHP IP.Content block fairly easily.

Link to comment
Share on other sites

Nope, not wanting to show anything (in this example) in Event Display View (your mod already does that). I'm wanting to display the values of my Calendar Template custom fields inside IP.Content, not IP.Calendar.


Here is an "Upcoming Events" feed block I have made in IP.Content (using the default feed that comes with IPC, just modified slightly with my own custom CSS to display the pictures)
post-202568-0-65575400-1327447957.jpg

I would like it to also show 'some' of the custom fields I added in Calendar Templates.

An example would be a custom field called "Entry Price".

So I could then show all upcoming events including their entry price in my IP.Content feed block.

I would like to pick and choose what I display in the block, such as the field value, field label, field description, etc.

Because these custom fields created by your mod are added to "cal_events" database table, I'm hoping there won't be too much extra coding to add to my block feed, as it is already looping results from $events (cal_events).

I know it's extra work, but pretty confident once it's demonstrated to people how you can do this with your mod, interest with skyrocket ;-)

My theory was what Marcher just said, but no idea how to code it, and if there is any easier way using a class you made, that would be even better.

Link to comment
Share on other sites


Nope, not wanting to show anything (in this example) in Event Display View (your mod already does that). I'm wanting to display the values of my Calendar Template custom fields inside IP.Content, not IP.Calendar.


I did get you weren't referring to the Calendar, I just meant if you wanted to pull the exact view into IP.Content. In either case, I understand now what you want to do. :wink:

So... here we go. Hopefully I don't confuse the hell out of everyone, but if I do, feel free to ask questions, I'll be happy to answer!

The primary class you need to worry about is called cts_view. So the first step is to load the class.

$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('caltemplate').'/sources/classes/views.php', 'cts_view', 'caltemplate');

$this->ctsView = new $classToLoad();

Now, you want to load the current Calendar Template. To do this, you need to know the following three things: - Template in use for the selected event (located in cal_events.set_id) - Calendar ID (cal_events.cal_id) - Event ID (cal_events.event_id)

$this->ctsView->loadTemplate($setId, $calendarId, $eventId);

The above line will load all template fields and ALL properties, including label, field type, description, instructions, current value, etc, etc, etc. You can then loop through the fields using

foreach($this->ctsView->template['fields'] as $field)

Each field will have the following properties:

  • $field['field_id'] The unique ID of the field
  • $field['name'] The name of the field
  • $field['label'] The label for the field
  • $field['description'] The description of the field
  • $field['field_type'] Valid values: checkbox, dropdown, image, multi, multicheck, radio, text, textarea
  • $field['options'] The available options for multi-value fields (dropdown, multi, multicheck, radio). This data is stored as a serialized array. I don't recommend parsing this... the data is parsed into $field['form'] to properly render the form field.
  • $field['validation_type'] Valid values: numeric, email, date, url
  • $field['instructions'] Data entry instructions for this field
  • $field['required'] 0/1, 1 if the field is required for this template
  • $field['default_value'] Contains the default value used for this field if left empty
  • $field['value'] The current value for this field in this event.
  • $field['form'] The HTML for the actual form field. This should NOT be used for standard display.
Now, let's say you've got some kind of custom PHP block that is pulling events. Your code MIGHT look something like this:


$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('caltemplate').'/sources/classes/views.php', 'cts_view', 'caltemplate');

$this->ctsView = new $classToLoad();


$this->DB->build(array('select' => '*', 'from' => 'cal_events', 'limit' => array(0,5)));

$query = $this->DB->exceute();

while($event = $this->DB->fetch($query))

{

	$this->ctsView->loadTemplate($event['set_id'], $event['cal_id'], $event['event_id']);

	if(is_array($this->ctsView->template['fields']) && count($this->ctsView->template['fields']))

	{

		foreach($this->ctsView->template['fields'] as $field)

		{

			if($field['name'] == 'price')

				$event['price'] = $field;

		}

	}

	unset($this->ctsView->template);

}

$this->DB->freeResult($query);



Then you could use $event['price']['label'], $event['price']['value'], etc, etc.

Hope this helps....

Link to comment
Share on other sites

Okay, I understand (sort of) what you just said, but failed to put it into practice.

My Calendar block is a Feed Block, which is what most people would use. I want to add your code to my block but it's HTML only. If I built a new PHP block, I would need to understand how to code the Calendar 'feed' from scratch :(

The default Feed Block that comes with IP.Content is simply this (the Feed code itself is hidden from our view):


<div class='general_box'>

<h3>{$title}</h3>

<ul class='hfeed'>

  <if test="is_array( $records ) && count( $records )">

  {parse striping="feed_striping" classes="row1,row2 altrow"}

  <foreach loop="$records as $r">

  <li class='hentry {parse striping="feed_striping"}'><a href='{$r['url']}' rel='bookmark' title='{$r['title']}'>{$r['title']}</a>

   <br /><span class='date'><abbr class="published" title="{parse expression="date( 'c', $r['date'] )"}">{parse date="$r['date']" format="short"}</abbr></span>

   <span class='desctext'>{IPSText::truncate( strip_tags($r['content']), 32 )}</span>

  </li>

  </foreach>

  </if>

</ul>

</div>

<br />

How would the code you provided fit into the Feed Block above? I woud like to insert it somewhere after the


<foreach loop="$records as $r">

.

It is possible to do it this way, or must we use a blank PHP block?

Link to comment
Share on other sites


Okay, I understand (sort of) what you just said, but failed to put it into practice.



My Calendar block is a Feed Block, which is what most people would use. I want to add your code to my block but it's HTML only. If I built a new PHP block, I would need to understand how to code the Calendar 'feed' from scratch :sad:



The default Feed Block that comes with IP.Content is simply this (the Feed code itself is hidden from our view):



<php>

$classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('caltemplate').'/sources/classes/views.php', 'cts_view', 'caltemplate');

$this->ctsView = new $classToLoad();

</php>

<div class='general_box'>

<h3>{$title}</h3>

<ul class='hfeed'>

  <if test="is_array( $records ) && count( $records )">

  {parse striping="feed_striping" classes="row1,row2 altrow"}

  <foreach loop="$records as $r">

<php>

$this->ctsView->loadTemplate($r['set_id'], $r['cal_id'], $r['event_id']);

        if(is_array($this->ctsView->template['fields']) && count($this->ctsView->template['fields']))

        {                

foreach($this->ctsView->template['fields'] as $field)               

  {                        

if($field['name'] == 'price')     

{

 $r['price'] = $field;  

}             

}        

}        

unset($this->ctsView->template);

</php>

  <li class='hentry {parse striping="feed_striping"}'><a href='{$r['url']}' rel='bookmark' title='{$r['title']}'>{$r['title']}</a>

   <br /><span class='date'><abbr class="published" title="{parse expression="date( 'c', $r['date'] )"}">{parse date="$r['date']" format="short"}</abbr></span>

   <span class='desctext'>{IPSText::truncate( strip_tags($r['content']), 32 )}</span>

  </li>

  </foreach>

  </if>

</ul>

</div>

<br />

How would the code you provided fit into the Feed Block above? I woud like to insert it somewhere after the


<foreach loop="$records as $r">

.

It is possible to do it this way, or must we use a blank PHP block?


its "dirty" but so long as regex in the template itself is not needed, <php> tags suffice in feeds.
Link to comment
Share on other sites

Marcher, I couldn't use your code to display any of the content from the custom fields.

I created a custom field in Calendar Templates simply called "price", but when I try to use


{$r['price']}

in my block (inside the record loop) it just outputs the word "array". So I replaced:


if($field['name'] == 'price')	

{

$r['price'] = $field;

with this:


if($field['name'] == 'price')	

{

$r['price'] = $field['value'];


and that worked. Any problems with that?


@ee_joseph.
From what I can see it doesn't work that way. You (the admin) create a series of fields or questions that the event creator has to fill out. You cannot add fields/questions/options for normal members to fill out when they RSVP or comment the Event. It would be nice if there was another option to define a template for replies but the default commenting system in IP.Calendar is pretty basic.

Link to comment
Share on other sites



@ee_joseph.


From what I can see it doesn't work that way. You (the admin) create a series of fields or questions that the event creator has to fill out. You cannot add fields/questions/options for normal members to fill out when they RSVP or comment the Event. It would be nice if there was another option to define a template for replies but the default commenting system in IP.Calendar is pretty basic.




ah :(. I need that, I wish someone would create it and save me the trouble :(.
Link to comment
Share on other sites

Just purchased and installed :)

A FYI Esther, not sure if this is an issue or not, but at the end of the installation process, I got this in the header:

Warning: Invalid argument supplied for foreach() in /home/talkford/public_html/admin/applications_addon/other/caltemplate/sources/cache.php on line 62

Link to comment
Share on other sites

Has anyone managed to get this working with DevFuse' Calendar Topics? I know it was working in a beta stage, but I have both full versions and get errors when I try to create a new event.


Fatal error: Cannot redeclare class class_loader in /home/username/public_html/admin/applications_addon/other/topictemplate/sources/helpers/class_loader.php on line 20



If I have a Template available in my drop-down, but don't use it, then I can create an Event successfully. My guess is that both mods conflict and try to do similar things. Can this mod be made to work with it (or just as happy if you make your own mod to do this, that parses all our custom fields).

Link to comment
Share on other sites


Marcher, I couldn't use your code to display any of the content from the custom fields.



I created a custom field in Calendar Templates simply called "price", but when I try to use


{$r['price']}

in my block (inside the record loop) it just outputs the word "array".


The $r['price'] would give you all the properties of the field (in case you needed the label, field type, etc). Working with the original example, what you wanted to use was
{$r['price']['value']}

What you have above is fine as well (again, unless you want to grab the label, description, etc.).
Link to comment
Share on other sites


A FYI Esther, not sure if this is an issue or not, but at the end of the installation process, I got this in the header:



Warning: Invalid argument supplied for foreach() in /home/talkford/public_html/admin/applications_addon/other/caltemplate/sources/cache.php on line 62



I'll fix that today.


Has anyone managed to get this working with DevFuse' Calendar Topics? I know it was working in a beta stage, but I have both full versions and get errors when I try to create a new event.




Fatal error: Cannot redeclare class class_loader in /home/username/public_html/admin/applications_addon/other/topictemplate/sources/helpers/class_loader.php on line 20



If I have a Template available in my drop-down, but don't use it, then I can create an Event successfully. My guess is that both mods conflict and try to do similar things. Can this mod be made to work with it (or just as happy if you make your own mod to do this, that parses all our custom fields).


That error is unrelated to the DevFuse mod - that's because you have both the Calendar Templates and the Topic Templates mods installed (and I appear to have made a moronic mistake ;)). Fix will be posted (in THIS mod) today.
Link to comment
Share on other sites

A new version has been uploaded to the Marketplace. It contains the following changes:

  • PHP error (related to caching) after initial installation. Fixed.
  • Conflicting class with [HSC] Topic Template System. Fixed.
  • Image fields now support the alt and title attributes.
Link to comment
Share on other sites

I received this error after installing the mod while looking thru the ACP settings:


Warning: Invalid argument supplied for foreach() in /applications_addon/other/caltemplate/modules_admin/templates/calendars.php on line 207  Error

Please Wait...


Link to comment
Share on other sites

OK, admittedly I'm new to IPB and a convert from vB so I don't know what the support standards are on marketplace. I paid for this mod on the 1st, it has what appears to be an obvious coding error, and no response from the dev for 2 days. I need to get this mod up and running!

Link to comment
Share on other sites


OK, admittedly I'm new to IPB and a convert from vB so I don't know what the support standards are on marketplace. I paid for this mod on the 1st, it has what appears to be an obvious coding error, and no response from the dev for 2 days. I need to get this mod up and running!



Not to be rude or anything, but it hasn't even been 48 hours yet.

I did see your message, and I've been trying to reproduce this, but can't. Can you please provide me with some more information - for example, what screen were you on exactly when this error occurred? Have you created any fields yet? How about templates?

Thanks.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...