Welcome, Guest
Username: Password: Remember me

TOPIC: List from the current date as a custom field date

List from the current date as a custom field date 11 Sep 2012 10:16 #3515

  • sarki
  • sarki's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Karma: 0
I created a component reservation for three courses with three interfaces for managing dates and three interfaces for managing reservations.
Each reservation management and linked with the management of the corresponding course dates.
www.ecole-conduite-yverdon.ch

I try to only list the dates from current day.

I have done in the modules that I created using queries like:
$query->where('publish = 1 AND startsensibi > curdate() - 1 ');
After several days of research and testing, I have not found how to incorporate this condition, I tried to add it to the file folder "model", but it only works if I am logged in and filters no longer work :
. 'WHERE startsensibi > curdate() - 1'

Someone has an idea? Because there is beyond my skills, I do not know where to look.

I made a topic in French, because my English is bad : www.j-cook.pro/forum/30-debug/3455-tri-s...is-codage-de-ma-part
Sarki
Last Edit: 03 Oct 2012 13:42 by admin.
The administrator has disabled public write access.

Re: List from the current date as a custom field date 12 Sep 2012 20:12 #3547

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
instead of 'publish', use 'published'

Because now the publish mode requires that the field is named 'published'

Then, try with 'a.published', in that case, it cannot conflicts with another published field (other linked table)
Also because if you use the table alias (a.) you do not need to brace you field name (`field_name`)

Your second example is coming from 1.5, right ?

I think the first one is almost good if you correct it with 'a.published'.


One thing also to understand is the switch() that fills a different SQL profile, depending of the called layout.
Means that you may choose carefully where you put your code, or to put it at the end, called every time.


Another facultative point about the SQL personalisation (filters) :
You can use the states vars of the model. It id really easy.
You can decide to call in the VIEW:
$model->setState('filter.date.today', true); //Choose any name you want for this state value

And in the model :
if ($this->getState('filter.date.today'))
	$query->where('a.published = 1 AND startsensibi = curdate()');

In this way it is clean, and you can understand the use of the states vars.
The states vars are uses as switchers to change the behaviors or the model. Clever, no ?
By the way, it replace the activate() function in Cook 1.x (Now deprecated since the use of the states vars)
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: sarki

Re: List from the current date as a custom field date 13 Sep 2012 11:03 #3570

  • sarki
  • sarki's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Karma: 0
Hello Jocelyn.
For the module I did not make a mistake, I am still with version 1.5

I did not find where to put the condition in the model, I tried several places but it gives me an error.
I tried to put the condition in a function, or create a new one but without success.

Could you answer me in French on this thread, my English is limited, it will be easier for me, thank you:
www.j-cook.pro/forum/30-debug/3455-tri-s...is-codage-de-ma-part
Sarki
The administrator has disabled public write access.
Time to create page: 0.099 seconds

Get Started