Calendar Events Search Page - customising


(Stuart W) #1

I wonder if anyone might be able to point me in the right direction in customising a Calendar Events Search Page (CESP) please?


Here’s what I have:



On this page I have a CESP that allows users to search for archived meetings by year. So far I have done the following:


  • set an initial search on the Search Fields settings page - creating an Events Date Filter Configuration called startdate, filtering by a [b]Date Range[/b]
    [*]displayed links to the meetings that have taken place in the current year by setting the [b]Show the Results page[/b] option on the Details page to [b]Yes[/b], and where I nest the CESP, sending the GET variable '[b]startdate[/b]' to the asset with value [b]01-01-%globals_date_Y%,%globals_date_d%-%globals_date_m%-%globals_date_Y%[/b]
    [*]I have then looked at setting up the option for users to select the year, and since I only want users to select from the years, I have hard coded the search fields as follows:

    <code>

    <script type='text/javascript'>
    $(function() {
    $('#startdateFromYear').change(function() {
    // if changed to, for example, the last option, then
    // $(this).find('option:selected').text() == D
    // $(this).val() == 4
    // get whatever value you want into a variable
    var x = $(this).val();
    // and update the hidden input's value
    $('#startdateToYear').val(x);
    });
    });
    </script>

    Select year:
    <input type="hidden" name="queries_startdate_fquery_fromshow" value="ymd" />

    <input type="hidden" name="queries_startdate_fquery_fromvalue[d]" id="queries_startdate_fquery_fromvalue[d]" value="1" />

    <input type="hidden" name="queries_startdate_fquery_fromvalue[m]" id="queries_startdate_fquery_fromvalue[m]" value="1" />

    <select name="queries_startdate_fquery_fromvalue[y]" id="startdateFromYear" class="sq-form-field">
    <option value="2010">2010</option>
    <option value="2011">2011</option>
    <option value="2012">2012</option>
    </select>

    <input type="hidden" name="queries_startdate_fquery_fromvalue[h]" value="" />
    <input type="hidden" name="queries_startdate_fquery_fromvalue[i]" value="" />
    <input type="hidden" name="queries_startdate_fquery_fromvalue[s]" value="" />

    <input type="hidden" name="queries_startdate_fquery_toshow" value="ymd" />

    <input type="hidden" name="queries_startdate_fquery_tovalue[d]" id="queries_startdate_fquery_tovalue[d]" value="31" />

    <input type="hidden" name="queries_startdate_fquery_tovalue[m]" id="queries_startdate_fquery_tovalue[m]" value="12" />

    <input type="hidden" name="queries_startdate_fquery_tovalue[y]" id="startdateToYear" value="" />

    <input type="hidden" name="queries_startdate_fquery_tovalue[h]" value="" />
    <input type="hidden" name="queries_startdate_fquery_tovalue[i]" value="" />
    <input type="hidden" name="queries_startdate_fquery_tovalue[s]" value="" />

    %submit_button%

    </code>
    [*]As you will see, the inputs for days and months are set to the 1st Jan for the from date and 31 December for the to date. The javascript sets the to year to be the same as the from date, so the actual search looks for events from the 1 Jan to the 31 Dec in the chosen year.

Here's what I'd like to do (and could do with a pointer or two please!)[list]
[*]Include a subtitle above the results, something like [b]Meetings from [year][/b] - where [year] is the year that the user has searched for.
I did manage to do this when there were results found by using a grouping and displaying the group name, but that didn't work when there were no results.
Another thought I had was to use the keyword %<field_name>_query_terms%, but no matter what I entered for <field_name> (I tried [b]startdate[/b] and also [b]queries_startdate_fquery_fromvalue[y][/b]), nothing displayed on either the Results Page Layout or the No Results Page Layout. I suspect it is because I have hard coded the search inputs.
[*]Make the drop down box for the user to select the year to search on auto-fill from the start dates of the events that are available to search on.
I am not really sure how to go about this - I guess by having another search and somehow filtering the results of it to find the date of the earliest one in the list - but any thoughts on this would be very much appreciated.
[/list]
Finally, do you think I am going about this the right way, using a CESP, or should I be using a different kind of asset altogether to create my searchable archive? I've only been using Matrix for 8 months, so am more than happy to be told that I would be better using a different sort of asset!

Many thanks for any help you can give me.

Cheers,

Stu

Stuart Willis
Website Officer

Yorkshire Dales National Park Authority,
Colvend, Hebden Road, Grassington, Skipton,
North Yorkshire BD23 5LB.

Direct line: 01756 751640
Email: [email="stuart.willis@yorkshiredales.org.uk"]stuart.willis@yorkshiredales.org.uk[/email]
Website: this page

(Phil Mcphee) #2

Hi Stu


I reckon to get your subtitle to work, you could probably take data from the GET parameters in the URL using the %globals_get_% keyword. There are loads of parameters in the URL for that page, but from a quick glance you could maybe use queries_startdate_fquery_fromvalue[y], so your keyword would be %globals_get_queries_startdate_fquery_fromvalue[y]%



The second question seems a bit trickier to me… my approach would be to break up all my events into folders (eg. 2010, 2011 etc) and then use an asset listing to pump out that drop-down. Probably not very helpful, but I can't think of a better way to do it;)



Hope that's at least a start… good luck from a former resident of North Yorkshire!


(Stuart W) #3

Cool - thanks, Phil - that gives me a great tip on where to go from here. I didn't even know you could access GET variables so I have learned something else very valuable too! I'll have a play later.


Cheers

Stu


(Stuart W) #4

This is hard!

 

I have tried accessing %globals_get_queries_startdate_fquery_fromvalue[y]%, but as you will see from

 

http://www.yorkshiredales.org.uk/livinghere/sustainabletourism/europarc/dalestourismsteeringgroup/tourism-steering-group-meetings/_nocache?startdate=1-1-2012%2C10-12-2012&queries_startdate_fquery_fromshow=ymd&queries_startdate_fquery_fromvalue[d]=1&queries_startdate_fquery_fromvalue[m]=1&queries_startdate_fquery_fromvalue[y]=2010&queries_startdate_fquery_toshow=ymd&queries_startdate_fquery_tovalue[d]=31&queries_startdate_fquery_tovalue[m]=12&queries_startdate_fquery_tovalue[y]=&page_calendar_events_search_284831_submit_button=Submit&current_result_page=1&results_per_page=0&submitted_search_category=&mode=

 

Matrix just prints out the keyword rather than displaying the value of the variable. I read in the user manuals that 'Only scalar variables can be used as global keyword replacements. Arrays are not supported.' Is this why the keyword is not working for me?

 

Another thing - when I do a second search, the initial querystrings aren't cleared from the url. Rather, new ones are added to the url. Is this correct? Is there a way of stopping this?

 

I'm beginning to think that what I want to do is beyond what I can do in Matrix and that I need to think about a different way of doing it. Any thoughts greatly appreciated.

 

Cheers

 

Stu


(Stuart W) #5

Think I have solved it, and the solution involved making sure that there will be no searches without results. In other words, I have moved all meeting single calendar events into folders for their respective year and set up an asset listing to auto-generate the drop-down for the year search. With a bit of simple javascript I have been able to make sure that only searches up to today's data can be made, and also that users cannot search for years where there are no meetings. Accordingly, it is impossible to do a search where there are no results and I don't need to worry about the no results layout!

 

Hurrah!

 

Stuart