Single value of drodown menu should be unpublished when expired

Hotkeyharry 11 Mar, 2019
How to do that?

For example:
If the value/event of the dropdown menu is 2019-03-11 20:00 it should be unpublished at 2019-03-12 00:00

I'm an unexperienced chronoforms user and can't find any hint or a way to do that, sorry...

thanx in advance
Harald
Max_admin 11 Mar, 2019
Hi Harald,

You can generate your dropdown options dynamically using PHP and check the values, use a PHP action which returns an associative array and call the php var in the options of your dropdown:
{var:php_action_name}
Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hotkeyharry 11 Mar, 2019
Hi Max,

thats strong. Are there any similar examples/threads on your site?

best regards
Harald
healyhatman 11 Mar, 2019
Where are you getting your dropdown values from?
Hotkeyharry 11 Mar, 2019
Hi healyhatman,

the dropdown values are manually driven... ;-(

It is a list like this:

05.04.2019 - Ortho-Bionomy erlernen - 260 €=05.04.2019 - Ortho-Bionomy erlernen - 260 €
05.04.2019 - 17.11.2019 - Gesamtausbildung 2019: Energetische Psychotherapie AEP nach Fred Gallo - 1.720 €=05.04.2019 - 17.11.2019 - Gesamtausbildung 2019: Energetische Psychotherapie AEP nach Fred Gallo - 1.720 €
05.04.2019 - 07.04.2019 - Einführung und Level 1 Energetische Psychotherapie AEP nach Fred Gallo - 370 €=05.04.2019 - 07.04.2019 - Einführung und Level 1 Energetische Psychotherapie AEP nach Fred Gallo - 370 €
05.07.2019 - 07.07.2019 - Einführung und Level 1 Energetische Psychotherapie AEP nach Fred Gallo - 375 €=05.07.2019 - 07.07.2019 - Einführung und Level 1 Energetische Psychotherapie AEP nach Fred Gallo - 375 €

best regards
healyhatman 11 Mar, 2019
Yeah that sucks, you should probably think of how to put it in a database instead with a start date and end date or whatever.

Either way, for now you'll have to use PHP to extract the date from the string, compare it with today's date, and return a new list with just the right entries, and use that in your dropdown (as {var:phpblockname}).
Max_admin 11 Mar, 2019
Your form should be as its, but in the dropdown options, write this:
{var:doptions}
Then, in your form "load" event, drag a PHP action ABOVE the "Display form", name the PHP action "doptions", then use a code like this:
$options = array();

if(time() < strtotime("05.04.2019")){
$options[] = "05.04.2019 - Ortho-Bionomy erlernen - 260 €";
}

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hotkeyharry 11 Mar, 2019
Hi Max,

thank you very much for the great help, and although I don't have KnowHow in PHP, I understand what the code means. It seems to be very logical.
I've put it in joomla, but I can't get it running, it's a great pity...and unfortunately I don't know how to troubleshoot the code...

best regards
Harald
Hotkeyharry 12 Mar, 2019
latest test: The row in the Dropdown will not be rendered, its a pity...
healyhatman 12 Mar, 2019
You need to return the options array too at the end of the PHP block. What does your code look like right now?
Hotkeyharry 12 Mar, 2019
Hi Healyhatman,

I've did it exactly like Max in Thread

March 11 at 17:54
#384707
wrote.
???
best regards
Harald



{var:doptions}
$options = array();if(time() < strtotime("05.04.2019")){$options[] = "05.04.2019 - Ortho-Bionomy erlernen - 260 €";}
healyhatman 12 Mar, 2019
That was just an example. You need to return the $options array once you've finished filling it
Hotkeyharry 12 Mar, 2019
thanx, but sorry, but I don't have knowledge in PHP coding ;-(
healyhatman 12 Mar, 2019
Ah well. Not that hard to learn that. Do you NEED to have them manually coded in, or can you store them in a database? Because that would make more sense and be a lot easier.
Hotkeyharry 12 Mar, 2019
I cannot overlook the pros and cons of manually and/or database, but the feeling says database ;-)

My wish would be: the user puts his event or his events himself as a list into a post. (So he can maintain the events forever himself)

05.04.2019 - Event 1 - 111€
06.04.2019 - Event 2 - 111€
05.12.2019 - Event 3 - 111€ and so on...

From there the events has to be taken over in to the dropdown field of chronoforms (with php?)

With Max (unready) php-code the event is unpublished after expired.
healyhatman 12 Mar, 2019
With the database you can store a start date, an end date, a description, a price, and whatever else you need. And then read the database and, say, ONLY retrieve the ones that aren't expired yet.
This topic is locked and no more replies can be posted.