-
MODX Staff
- 2,502 Posts
I want to create a plugin or snippet that will set the unpubdate timestamp to the timestamp set in a tv called "eventDate" + 3600 86400 seconds (one day after the event happens.
I am thinking I would need to use the OnTemplateFormSave event to do this but I am not sure. I am currently struggling with Soda’s Front End Document Manager not saving dates and times and it would be easier anyway if I could just have the document unpublish automatically the day after the event.
I certainly know I could make the events show up or hide using PHx but I want them to be invisible to bots and searches.
If someone could point me in the right direction that would be good.
All the best,
Jay
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
Nimja,
Thanks for the response,
The reason for the automatic unpublish is that the client is using Ditto for a Upcoming Events System and I implemented Soda’s Front End Document Manager and it is not storing the unpublish dates and also since the dates will always be the same (1 day after the event) it makes sense for MODx to handle this instead of the client having to do it every single time.
I find the calendar widget annoying as it is so reducing the number of times someone has to use it is great.
Cheers,
Jay
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
Well if you want to learn something yourself, find out how to read template variables in a document (which should be easy)
And then simply update the end-date with a nice PHPDATE + 1 day.
If only I could remember by heart how to read TV’s
-
MODX Staff
- 2,502 Posts
Okay...Hmmm.
I think what I would like to do is do something like
Here is where I am lost.
If I use FDM (Front End Document Manager) it has fields that (using eForm) post input data to the db based on the field names.
I don’t want to apply this snippet/plugin to all documents but only those for a certain template.
I want the function to run on the FDM form save/post.
I don’t think this will work because the field info won’t yet be in the db to get. It will still be in the form.
I think that the only way to do this is to actually create a hidden field in the form and use PHx to do the calc in the value and hope that the value actually gets saved.
Thoughs?
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
sirlancalot,
Thanks for the tips. I was writing the post with the 3600 seconds it is obviously 86400--brain freeze.
Cheers,
Jay
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
I admit that I am not the most adept php guy and without asking people to write the plugin for me any suggestions of previously written plugins that might use the OnDocFormSave? Otherwise options as to how to achieve this.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
Okay I have tried to start by outputting the values from the event_date TV and I keep getting the following error:
Fatal error: Call to undefined function getTemplateVar() in C:\xampp\htdocs\nqnh\manager\includes\document.parser.class.inc.php(766) : eval()'d code on line 2
I just did this with a snippet to start just to see if I could return the value before I went on to write the plugin. I may have written it wrong but here it was:
<?php
$idname = 'event_date';
echo getTemplateVarOutput($idname);
?>
You may need to make fun of me for my messy or wrong code but I want to be able to figure this out.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub