• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: CGCalendar change interval of event times from 15 minutes
PostPosted: Thu Nov 22, 2012 2:59 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1427
Location: Maidenhead, UK
Edited 18 Dec 2012 to use the better method described in the first few replies below. Edited 5 Dec 2018 to use "assets" folder.

CGCalendar is very lovely for displaying events in different ways on your website. The default granularity when you add/edit events is every 15 mintes: so 00, 15, 30, 45 minutes past the hour. The time is entered as a dropdown box.

What if you have an event that starts at 15:10? You then need to change the time dropdown box to show every 5 minutes: so 00, 05, 10, 15, 20....through to 55.

Here's how. (See the Customizing Admin templates page of the docs area for the general method.)

Create a new directory assets/module_custom/CGCalendar/templates/

Copy the 3 files admin_add_event.tpl, orig_editevent_template.tpl, settings.tpl from modules/CGCalendar/templates/ across to your new directory.

Open assets/module_custom/CGCalendar/templates/admin_add_event.tpl
Search for "interval=" and around line 105 you will see
\$1:
<span id="starttime"{if $event.all_day_event == 1} style="display: none;"{/if}> @ {html_select_time use_24_hours=$use24 prefix=$tmp time=$event.event_date_start_ut minute_interval=15 display_seconds=false}</span>

Change the 15 to 5 (or whatever)

Search for "interval=" and around line 117 you will see
\$1:
{html_select_date prefix=$tmp  time=$event.event_date_end_ut start_year=$start_year end_year=$end_year}<span id="endtime"{if $event.all_day_event == 1} style="display: none;"{/if}><br/>@ {html_select_time use_24_hours=$use24 time=$event.event_date_end_ut prefix=$tmp minute_interval=15 display_seconds=false}</span>

Change the 15 to 5 (or whatever)


Open assets/module_custom/CGCalendar/templates/orig_editevent_template.tpl
Search for "interval=" and around line 47 you will see
\$1:
<span id="starttime"{if $event.all_day_event == 1} style="display: none;"{/if}> at {html_select_time use_24_hours=$use24 prefix=$tmp time=$event.event_date_start_ut minute_interval=15 display_seconds=false}</span>

Change the 15 to 5 (or whatever)

Search for "interval=" and around line 58 you will see
\$1:
<span id="endtime"{if $event.all_day_event == 1} style="display: none;"{/if}> at {html_select_time use_24_hours=$use24 time=$event.event_date_end_ut prefix=$tmp minute_interval=15 display_seconds=false}</span>

Change the 15 to 5 (or whatever)


Open assets/module_custom/CGCalendar/templates/settings.tpl
Search for "interval=" and around line 108 you will see
\$1:
{html_select_time prefix=$tmp display_seconds=false time=$dflt_starttime minute_interval=15}

Change the 15 to 5 (or whatever)

And you're done ;D

$1:
File comment: Time drop down showing 5 minute intervals
5minutes.jpg
5minutes.jpg [ 35.31 KiB | Viewed 4597 times ]


Last edited by paulbaker on Tue Dec 18, 2012 5:15 pm, edited 1 time in total.

Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Thu Nov 22, 2012 3:14 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8170
Location: Fernie British Columbia, Canada
Please revise this post to use the module_custom technique instead of modifying distributed files :)

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Thu Nov 22, 2012 3:20 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1427
Location: Maidenhead, UK
Sorry, I thought we were allowed to modify template files. I will modify the solution and post again when I have done so.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Fri Nov 23, 2012 8:39 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 350
Dear Paul,

You will need to create the folder "module_custom/modules/CGCalendar/templates/"
Then, create blank files named "admin_add_event.tpl", "orig_editevent_template.tpl" & "settings.tpl"

In the content of these files you will need to search & replace the stuff you want to change by using regex_replace.

Below an example for the blank admin_add_event.tpl file:
\$1:
{include file='file:##REPLACE_WITH_YOUR_SERVER_PATH##/modules/CGCalendar/templates/admin_add_event.tpl' assign='capturedtemplate'}
{$capturedtemplate|regex_replace:"/(##STUFF TO SEARCH FOR##)/":"##REPLACE WITH##"}
(note: i think that by including the file, the smarty code will aready be parsed... maybe you will need to use fetch? http://www.smarty.net/docsv2/en/languag ... .fetch.tpl )

I usually like to test regex_replace in http://gskinner.com/RegExr/

ps: When you convert it for usage in CMSMS you will need to "escape" some stuff with a backslash! (/ becomes \/)

The big advantage of using module_custom to make template changes is that can upgrade the modules without overwriting your changes! ;D

Greetings,
Manuel

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Sat Nov 24, 2012 3:28 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1427
Location: Maidenhead, UK
Thanks for the reply Manuel. I found a help document in docs about module_custom:
http://docs.cmsmadesimple.org/customizi ... -templates

In that, the suggestion is you paste the standard template in to your custom one, and alter it as necessary.

I suppose your method of grabbing the standard template each time and altering it with a regex is even better because if the standard template changes in future versions the changes will be preserved (unless the standard template changes the exact bit your regex is searching for, of course).

\$1:
You will need to create the folder "module_custom/modules/CGCalendar/templates/"


I don't think you need "modules/" in there?

I tried your method but I can't get it working.

In new file /home/cthuk/public_html/stmarys/module_custom/CGCalendar/templates/admin_add_event.tpl I have put:

\$1:
{include file='file:/home/cthuk/public_html/stmarys/modules/CGCalendar/templates/admin_add_event.tpl' assign='capturedtemplate'}
{$capturedtemplate|regex_replace:"/(minute_interval=15)/":"minute_interval=1"}


(I have put the original standard template files back so "minute_interval=15" does appear). The system is grabbing the .tpl file OK but the regex is not replacing the text.

I tried "{fetch file=..." but that didn't seem to work at all - just gave me a blank screen.

What am I doing wrong? ???


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Thu Nov 29, 2012 11:51 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 350
Dear Paul,

Below a quick test you can perform:
\$1:
{include file='file:/home/cthuk/public_html/stmarys/modules/CGCalendar/templates/admin_add_event.tpl' assign='capturedtemplate'}
INCLUDE: {$capturedtemplate|@debug_print_var:0:600}
<br><br>
{fetch file='/home/cthuk/public_html/stmarys/modules/CGCalendar/templates/admin_add_event.tpl' assign='capturedtemplate2'}
FETCH: {$capturedtemplate2|@debug_print_var:0:600}
When you "fetch" the file, you will need to "eval" the template to execute the smarty inside ;)
\$1:
{eval var=$capturedtemplate2}


Greetings,
Manuel

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Fri Dec 07, 2012 11:20 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 463
Manuel

IMHO, it seems to me like an lot of extra, unnecessary work. With module_custom, all you need do is create the comparable path, eg

\$1:
module_custom/MyModule/templates


Then create your customised template. Easiest way is to copy/paste the original then edit it as you wish.

Yes, module developers occasionally change templates in new versions, but that is an issue for us all anyway, whether frontend or admin, and hardly seems worth the additional overhead in 99.9% of cases. As Paul says, chances are the template change will affect the REGEX anyway so you'd still have to update the module_custom version.

I prefer to keep it simple. :)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGCalendar change interval of event times from 15 minute
PostPosted: Tue Dec 18, 2012 5:18 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1427
Location: Maidenhead, UK
Thanks manuel but I agree with psy on this, keep it simple. ;D

I have now edited the original post to use the module_custom technique; copying the template files and editing the copies.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting