- Posts: 3
COMMUNITY FORUM
Force Created Date in K2 Frontend
- Beppe De Lorenzis
- Topic Author
- Offline
- New Member
Less
More
7 years 2 months ago #164158
by Beppe De Lorenzis
Force Created Date in K2 Frontend was created by Beppe De Lorenzis
Hi,
i have a problem with a k2 frontend item.
By default, k2 sets as the date of creation of the item in the frontend the current date.
I, for my needs, would like to set this date automatically with a custom date (specifying the "manual" date in the file itemform.php) (I will then disable the text field)
For example, i would to set Creation Date of all K2 frontend item as "2017-09-22 12:12:00" without doing anything for the user
Thank's
i have a problem with a k2 frontend item.
By default, k2 sets as the date of creation of the item in the frontend the current date.
I, for my needs, would like to set this date automatically with a custom date (specifying the "manual" date in the file itemform.php) (I will then disable the text field)
For example, i would to set Creation Date of all K2 frontend item as "2017-09-22 12:12:00" without doing anything for the user
Thank's
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 months ago #164164
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Force Created Date in K2 Frontend
You can alter the value of an input field with JS, quite easily.
You can also add a disabled attribute so the user's cannot mess with it.
Look at these functions.
api.jquery.com/val/
api.jquery.com/attr/
You can also add a disabled attribute so the user's cannot mess with it.
Look at these functions.
api.jquery.com/val/
api.jquery.com/attr/
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Beppe De Lorenzis
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
7 years 2 months ago #164169
by Beppe De Lorenzis
Replied by Beppe De Lorenzis on topic Force Created Date in K2 Frontend
I tried to do this with jQuery but I had a problem: when I open the k2 frontend, the creation date is changed correctly with that indicated by me. but saving time is still set to the current date instead of the date indicated by me.
To solve, I did something "crude" but effective (file itemform.php):
To solve, I did something "crude" but effective (file itemform.php):
<tr>
<td align="right" class="key">
<?php echo JText::_('K2_CREATION_DATE'); ?>
</td>
<td class="k2ItemFormDateField">
<?php
$datacount = '2017-09-22 12:00:00';
//CUSTOM DATE HERE
$this->lists['createdCalendar'] = '<div class="field-calendar">
<div class="input-append">
<input id="created" name="created" value="'. $datacount.'" data-alt-value="'. $datacount.'" autocomplete="off" data-local-value="'.$datacount.'" type="text">
<button type="button" class="btn btn-secondary" id="created_btn" data-inputfield="created" data-dayformat="%Y-%m-%d %H:%M:%S" data-button="created_btn" data-firstday="1" data-weekend="0,6" data-today-btn="1" data-week-numbers="1" data-show-time="0" data-show-others="1" data-time-24="24" data-only-months-nav="0"><span class="icon-calendar"></span></button>
</div>
<div class="js-calendar" style="position: absolute; box-shadow: 0px 0px 70px 0px rgba(0, 0, 0, 0.67); min-width: 0px; padding: 0px; display: none; left: auto; top: auto; z-index: 1060; border-radius: 20px;"><div class="calendar-container"><table class="table" style="margin-bottom: 0px; visibility: visible;" cellspacing="0" cellpadding="0"><thead class="calendar-header"><tr class="calendar-head-row"><td colspan="1" style="text-align: center; font-size: 18px; line-height: 18px;" class=" nav"><a class="js-btn btn-prev-year" style="display:inline;padding:2px 6px;cursor:pointer;text-decoration:none;" unselectable="on">‹</a></td><td colspan="6" class="title"><div unselectable="on"><div style="text-align:center;font-size:18px"><span>2017</span></div></div></td><td colspan="1" style="text-align: center; font-size: 18px; line-height: 18px;" class=" nav"><a class="js-btn btn-next-year" style="display:inline;padding:2px 6px;cursor:pointer;text-decoration:none;" unselectable="on"> ›</a></td></tr><tr class="calendar-head-row"><td colspan="1" style="text-align: center; font-size: 2em; line-height: 1em;" class=" nav"><a class="js-btn btn-prev-month" style="display:inline;padding:2px 6px;cursor:pointer;text-decoration:none;" unselectable="on">‹</a></td><td colspan="6" style="text-align: center;" class="title"><div unselectable="on"><div style="text-align:center;font-size:1.2em"><span>Settembre</span></div></div></td><td colspan="1" style="text-align: center; font-size: 2em; line-height: 1em;" class=" nav"><a class="js-btn btn-next-month" style="display:inline;padding:2px 6px;cursor:pointer;text-decoration:none;" unselectable="on"> ›</a></td></tr><tr class="daynames wk"><td class="day-name wn">set</td><td class="day-name day-name-week">Lun</td><td class="day-name day-name-week">Mar</td><td class="day-name day-name-week">Mer</td><td class="day-name day-name-week">Gio</td><td class="day-name day-name-week">Ven</td><td class="day-name day-name-week">Sab</td><td class="day-name day-name-week">Dom</td></tr></thead><tbody><tr class="daysrow wk"><td class="day wn">35</td><td class="day disabled othermonth " style="text-align: center;">28</td><td class="day disabled othermonth " style="text-align: center;">29</td><td class="day disabled othermonth " style="text-align: center;">30</td><td class="day disabled othermonth " style="text-align: center;">31</td><td class="day" style="text-align: center; cursor: pointer;">1</td><td class="day weekend" style="text-align: center; cursor: pointer;">2</td><td class="day weekend" style="text-align: center; cursor: pointer;">3</td></tr><tr class="daysrow wk"><td class="day wn">36</td><td class="day" style="text-align: center; cursor: pointer;">4</td><td class="day" style="text-align: center; cursor: pointer;">5</td><td class="day" style="text-align: center; cursor: pointer;">6</td><td class="day" style="text-align: center; cursor: pointer;">7</td><td class="day" style="text-align: center; cursor: pointer;">8</td><td class="day weekend" style="text-align: center; cursor: pointer;">9</td><td class="day weekend" style="text-align: center; cursor: pointer;">10</td></tr><tr class="daysrow wk"><td class="day wn">37</td><td class="day" style="text-align: center; cursor: pointer;">11</td><td class="day" style="text-align: center; cursor: pointer;">12</td><td class="day" style="text-align: center; cursor: pointer;">13</td><td class="day" style="text-align: center; cursor: pointer;">14</td><td class="day" style="text-align: center; cursor: pointer;">15</td><td class="day weekend" style="text-align: center; cursor: pointer;">16</td><td class="day weekend" style="text-align: center; cursor: pointer;">17</td></tr><tr class="daysrow wk"><td class="day wn">38</td><td class="day selected today" style="text-align: center; cursor: pointer;">18</td><td class="day" style="text-align: center; cursor: pointer;">19</td><td class="day" style="text-align: center; cursor: pointer;">20</td><td class="day" style="text-align: center; cursor: pointer;">21</td><td class="day" style="text-align: center; cursor: pointer;">22</td><td class="day weekend" style="text-align: center; cursor: pointer;">23</td><td class="day weekend" style="text-align: center; cursor: pointer;">24</td></tr><tr class="daysrow wk"><td class="day wn">39</td><td class="day" style="text-align: center; cursor: pointer;">25</td><td class="day" style="text-align: center; cursor: pointer;">26</td><td class="day" style="text-align: center; cursor: pointer;">27</td><td class="day" style="text-align: center; cursor: pointer;">28</td><td class="day" style="text-align: center; cursor: pointer;">29</td><td class="day weekend" style="text-align: center; cursor: pointer;">30</td><td class="day disabled othermonth weekend" style="text-align: center;">1</td></tr><tr class="daysrow wk"><td class="day wn">40</td><td class="day disabled othermonth " style="text-align: center;">2</td><td class="day disabled othermonth " style="text-align: center;">3</td><td class="day disabled othermonth " style="text-align: center;">4</td><td class="day disabled othermonth " style="text-align: center;">5</td><td class="day disabled othermonth " style="text-align: center;">6</td><td class="day disabled othermonth weekend" style="text-align: center;">7</td><td class="day disabled othermonth weekend" style="text-align: center;">8</td></tr></tbody></table><div class="buttons-wrapper btn-group"><button data-action="clear" class="js-btn btn btn-clear">Annulla</button><button data-action="today" class="js-btn btn btn-today">Oggi</button><button data-action="exit" class="js-btn btn btn-exit">Chiudi</button></div></div></div></div>';
echo $this->lists['createdCalendar'];
//print_r( $this->lists);
?>
<script>jQuery('#created').prop('readonly', true);</script>
</td>
</tr>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 months ago #164176
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Force Created Date in K2 Frontend
Make sure that all of required inputs were changed.
You might have missed a spot.
You might have missed a spot.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.