I used component-creator.com to build a component. The component has a table with a date field and a frontend view which shows the contents of the table with a filter which can show the items between two dates. Here is a view from the backend:
That's great, but I only wanted to filter the db result by a single date, so I modified my site/models/sessions.php to include this line:
$filter_date_from = $this->state->get("filter.date_from_dateformat");
$filter_Qdate_from = (!empty($filter_date_from)) ? $this->isValidDate($filter_date_from) : null;
if ($filter_Qdate_from != null)
{
$query->where("a.date = '" . $db->escape($filter_Qdate_from) . "'");
}
and then modified my site/models/forms/filter_sessions.xml to include only this line:
<field name="date_from_dateformat" label="COM_MERAKIAC_LIST_LBL_SESSION_DATE_FILTER_FROM" type="calendar" onchange="this.form.submit();" filter="safehtml" class="inputbox"/>
Which, when I rebuild the component, allows me to filter my db by providing a single date:
Here is where I am stuck. I want to change the behavior of the calendar as such:
- I want the calendar to always appear on the page (inline), not at a popup triggered by a button, and certainly not hidden within any collapsible "search tools" menu.
- I would rather not see a text field at all--limiting the user to enter a date only by selecting it on the calendar.
- I want the user to be able to click on a single date on the calendar and see the db entries associated with that date.
- I want to control the CSS properties of the calendar for purposes of responsive web design.
Question 1: Am I correct in understanding I would have to hack .js and .css files built into Joomla itself to make these changes to the calendar? If so, my plugin could not be distributed to others unless they hack those files as well?
Since I couldn't find out how to control the standard calendar form field, I tried to hack the original calendar code from dynarch.com into my site/views/sessions/tmpl/default.php file with something like this (and a million variations):
<script>
Calendar.setup({
cont: "sample1",
inputField: "filter_date_from_dateformat"
});
</script>
<div id="sample1">
<input type="text" title="" name="filter[date_from_dateformat]" id="filter_date_from_dateformat" value="" maxlength="45" class="inputbox hasTooltip" onchange="this.form.submit();" />
</div>
But no matter what I try I can't seem to pass the date selected by the user on the calendar directly to my filter_sessions.xml file. So
Question 2: How can I collect a date from a visual calendar and pass it to my model to apply to the SQL query? Is there a way to do this with the dynarch calendar? Or am I stuck using the standard calendar form field?
Any insight is appreciated. Thank you!