Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)Searching in the template with command line argumentss
Pages: [1] 2 3   Go Down
Print
Author Topic: Searching in the template with command line argumentss  (Read 1993 times)
0 Members and 1 Guest are viewing this topic.
memobug
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: January 11, 2002, 05:39:00 AM »

With a lot of help from Kent and Matt, I think I have something interesting happening with my template.  The formatting leaves something to be desired, but the functionality is getting pretty close.

I was looking to create a template cause the calendarscript to compile chronological list of events from a single calendar, but filtering them on certain constraints passed on the command line.  Among the parameters were duration, country, state, maxevents..

Some of the command line arguments now working:

DURATION - Just the standard duration passed to the script to limit the list output to a certain number of days.  If unspecified I made it default to my own value, and I made it also accept the number with and without the "d" attached.  Usage is &duration=10 or &duration=10d.  Note: if you ask for more than 365 days, I cap it at 365 just so my script doesn't spin its wheels forever.

MAXEVENTS - This is a parameter to constrain the printed list to a fixed number of events in case there isn't space in the page environment for more.  I also created a default for this.  Usage example is &maxevents=12.  The default if unspecified is 25.

COUNTRY - This is filters on one of my custom fields, depending on the country where the event will occur.  To make it more flexible, you can search on a list of countries in the command line.  Usage example &country=USA,France,Belgium   NOTE: if the country is unspecified, all countries match.  If a STATE (see below) is specified, then the country defaults to USA

STATE - This filters on a second custom field in the database, the US state where the venue is held.  If unspecified it doesn't filter at all.  If any list of 2 or more characters is given as a state, COUNTRY defaults to US and the list will be searched.  My custom field uses the US postal codes for US and territories, so valid searches would be on series of the 2-character codes, separated by spaces or commas so you don't get inadvertent matches, like CA,KS without the comma would be CAKS and match AK.
Sample usage &state=CA,CO,OR,HI

HERE ARE THE SAMPLES!

Now for some real examples on a database made up of 33 international events from various countries.  Please note these search results are coming from the same template, just using different command-line arguments, which was the point!

1. Here is 365 days duration with no search terms. It caps out at a maxevents of 25(default) No terms matches all countries

2. Here is a 30 day duration

3. Here is a 365 day duration but with a cap of maxevents=10

4. Here is a 150 day search on events in California

5. Here is a search on events in France,Belgium,New Zealand and Australia with a maxevents=3 cap

6. Here is a hypothetical 365 day searchsearch on the coastal states of CA OR WA NY FL GA TX

Feel free to follow the links and experiment with changing the URL.  I will be working on cleaning up the template and the code, but I think this demonstrates the functionality.

Your comments are appreciated!

Matt

[This message has been edited by memobug (edited January 11, 2002).]

Logged

Regards,

Matt

jmeslie
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #1 on: January 11, 2002, 07:23:00 AM »

Hi, I was looking for the same functionality.   Is the hack posted on the site somewhere so that I can download?

------------------

Logged
Scott
Guest
« Reply #2 on: January 11, 2002, 12:59:00 PM »

Very nicely done. This is the kind of flexibility I designed the script to support, and I love it when people find ways to maximize its potential. Very nice work  

------------------
Scott
CalendarScript.com


Logged
memobug
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #3 on: January 11, 2002, 06:57:00 PM »

Thanks!

jmeslie, it is actually just a template, not a true hack because it doesn't involve any mods to calendarscript itself.  In any case, you can get a copy of this work in progress

 http://www.memobug.com/treebay/cgi-bin/calendarscript/templates/calendars/oldstyle/sampleG.html  

but please keep in mind that this particular template is complicated by the following

1)To use this template as-is you would need to have a "state" and "country" fields set up in your custom fields.  It also references a "city" field, but I'm not doing anything with that yet.  You would also need a details script to direct the browser to.  I'm using the one defined in the templates/calendars/oldstyle folder

2) The bulk of the code in this template is not the search functions, which would be fairly straightforward.  It's actually code to do the following

a) Display the event start and end date
b) Display the event start and end months, which might be different!
c) Avoid printing redundant event info, just one entry per event.

Kent gave me a basic algorithm for that which gathers the pertinent event data and pushes it into a list where it can be compared for redundancy and skip the repeat dates, just printing the endpoints.  I added in the month handling (which I kind of kludged because I don't know Perl well) and then added in the search, which is a little better.

In any case you can find the template and I padded out the blocks so you should be able to follow the nested loops and eliminate anything unnecessary for your application.  God help anyone who looks at the html output.  It's full of spaces and whatnot because of that.

The basic events list I was running before this is template sample here.

output sample here  It doesn't use any search terms or command line parameters and doesn't have any kind of removal of redundant events, but it's a good place to start.

Regards,

Matt

[This message has been edited by memobug (edited January 11, 2002).]

Logged

Regards,

Matt

Kent
New Member
*

Karma: 0
Offline Offline

Posts: 0

IT


WWW
« Reply #4 on: January 11, 2002, 08:45:00 PM »

Nicely done  

Cheers,
Kent

------------------

Logged
ToddHayes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #5 on: October 22, 2002, 12:21:00 PM »

Memobug's searching template would work great for me, if I can get it to work.

I copied his template to test, named it "sample.html", added a "state" field to the calendar and added the template name to ssi.txt. Using the following call in the command line:

calendar.pl?template=sample.html&state=VA

The template loaded my events correctly without errors, but it loaded all events in the calendar, instead of only those in VA.

In Memobug's live example, "no events" shows up when nothing matches the search query, so it seems that the searching function is not enaging on my server. What am I missing?

Thanks!

------------------

Logged
ToddHayes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: October 22, 2002, 12:35:00 PM »

OK, a CAPS error (sorry) interfered with the search function, and now the "no events" does show up using the same command. So it appears the search is looking for the state.

But, it's still not recognizing the entries for "VA" from the calendar. Anyone else have this problem?

------------------

Logged
ToddHayes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #7 on: October 22, 2002, 05:13:00 PM »

Ah ha! The script is fine.

My problem was with the field "state" I'd created to test it. It's a ghost field. It appears on the admin and user interface, but does not actually exist in the database, and cannot be deleted from the admin view. Easy enough to work around if there is no fix.

Memobug's script works beautifully and can be adapted to create new calendar views for any specific category or new field created. Very nice.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: May 13, 2003, 04:29:00 AM »

when one of my search results is an event with a wide range of days, all the other events that fall within that range are displayed as well...even if the country field for that event is blank....is that supposed to happen?

and is there a way to pass a parameter that will limit the results by keywords in the event details?

thanks ryan...

[This message has been edited by beneath_the_ashes (edited May 15, 2003).]

Logged
edat
Guest
« Reply #9 on: May 17, 2003, 01:13:00 AM »

I too am having this problem.
Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: May 24, 2003, 06:17:00 AM »

i also found that if i am not logged in to an account at all....the search results come back with every single event...only when im logged in do i have the problem i have above...

any thought?  i cant see anything...

thank you
ryan

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #11 on: May 30, 2003, 04:19:00 PM »

im getting down to the wire with these problems...if anyone can help me, i can kick a few bucks their way through paypal or something...or ad space...let me know

thnx
-brewster

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #12 on: May 30, 2003, 05:39:00 PM »

 
quote:
i also found that if i am not logged in to an account at all... the search results come back with every single event
I can't think of what could possibly cause that. Or more accurately, I don't see how that's possible unless whatever user you're logged in as doesn't have permission to view all of those events.

Dan O.


[This message has been edited by DanO (edited May 30, 2003).]

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #13 on: September 06, 2003, 06:19:00 AM »

i am still very much struggling with this issue, so if anyone feels friendly enough (or bored enough     to lend a hand, i am more than welcome to share my code!

my issue in summary?...well,
i have custom code that allows me to create events that can be public, private, or hidden.  public events are viewable by everyone, private keeps from seeing event details unless your logged in, and hidden keeps from seeing the entire event...

somehow...thats interfering with searching via this template method...

when i search with the template, it displays ALL the events.  However, if i am logged in with an account, for the computer that its logged in on, it displays correctly with just the events that i searched for....

here is the link to my add event page with the public, private and hidden options...

Add Event

here is the code in default.html for event view that displays events as they were created...

code:

<!-- EVENT VIEW -->
<% } elsif ($VIEW eq "Event") { %>
<% if (viewDetails($EVENT->{details}->{permissions})){ %>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<%
foreach (@$fields) {
next unless ($db->{'properties'}->{$_}->{'display_details'});
next unless ($EVENT->{details}->{$_});
$EVENT->{details}->{$_} =~ s/\r\n/<BR>/g;
%>
<font size="1" face="Verdana">
<TR><TD ALIGN="right" VALIGN="top"><SPAN CLASS="text"><B><%=$db->{'properties'}->{$_}->{'name'}%>:?
</B></SPAN></TD><TD ALIGN="left" VALIGN="top"><SPAN CLASS="text"><%=$EVENT->{details}->{$_}%></SPAN></TD></TR>
<% } %>
<%
($second, $minute, $hour, $date, $month, $year) = localtime($EVENT->{details}->{time_added} + $main::localtime_offset);
$month++;
$year += 1900;
%>
</font>
<TR><TD ALIGN="right" VALIGN="top"><SPAN CLASS="text">
 <font size="1" color="#CCCCCC">TimeAdded: </font></SPAN></TD><TD ALIGN="left" VALIGN="top"><SPAN CLASS="text"><font size="1" color="#CCCCCC"><%= $month %>-<%= $date %>-<%= $year %> @ <%=(($hour > 12)?$hour-12:$hour)%>:<% print sprintf("%02d",$minute); %> <%=(($hour > 11)?"PM":"AM")%></font></SPAN></TD></TR>

</TABLE></font>
<% ELSE %>
<p align="center"><b><font color="#FFFFFF">The details for this event are
PRIVATE!<br>
You must </font>
<a href="http://www.darkvisionsmedia.com/cgi-bin/calendar/calendar.pl?calendar=default&template=login.html">
<font color="#FFFF00">login</font></a><font color="#FFFFFF"> to view them.<br>
If you dont have an account, you need to </font>
<a href="http://www.darkvisionsmedia.com/Site/Body/Interact/Contact/default.asp">
<font color="#FFFF00">contact</font></a><font color="#FFFFFF"> me.<br>
But you will only get one if you are VIP.</font></b></p>
<% /IF %></font>


PLEASE!!! if anyone has any insight into this...it would be much appreciated...i have been struggling for months...and i can barely think about it anymore!!!

thanks much...

------------------


[This message has been edited by beneath_the_ashes (edited September 17, 2003).]

[This message has been edited by beneath_the_ashes (edited September 17, 2003).]

Logged
edat
Guest
« Reply #14 on: September 21, 2003, 09:31:00 AM »

can i get a username to login and look at your code?
Logged
Pages: [1] 2 3   Go Up
Print
Jump to: