0

I have a custom field "Time to Finish" in my custom content type in Drupal7. The "Time to Finish" is basically a timer of sorts. whenever the users click a flag (which is placed on nodes of that custom content type) the timer should start. The difficulty associated with this is that:

  1. Every node of that content type has different Time to Finish
  2. The timer should start on flag click (the flag is same on all node, "Start Flag")
  3. Every user would have their own timer then depending on when they click on the Start Flag

The admin while creating the content should have the option to fill in the field "Time to Finish" and on flag click the timer should start. Any suggestions. Would really appreciate it.

Thanks

Edit: I found this module which solves half of my issue,i.e, to assign every individual node their own Time To Finish field. Countdown Timer Field helped with this. Now i need that on "START FLAG" click the timer should start, not before that.

EDIT 2: i have opened a feature request issue for this at http://drupal.org/node/1948958 but can anyone help me do this. It will not only solve my use case but i think is a necessary feature to be added

EDIT 3: if there is any other solution i am eager to hear it as well.

19
  • What do you want to happen when the time is up? Commented Mar 21, 2013 at 10:06
  • well nothing much...just a plain simple message displayed, say, "Sorry Time's UP" ...Also there is another flag, "Stop" which on click stops the timer
    – why
    Commented Mar 21, 2013 at 10:11
  • What sort of time period would this be? seconds? hours? days? How accurate does the timer need to be? Commented Mar 21, 2013 at 10:16
  • DHM would be fine
    – why
    Commented Mar 21, 2013 at 11:03
  • Sorry, you missed the point of my question so maybe I didn't put it clearly enough. How long would a typical timer be? I guess from your answer it would be several days? And I assume there's some operation that will be blocked after this time, so the message will be in response to someone trying it. Is that correct? Commented Mar 21, 2013 at 11:15

1 Answer 1

1
+25

Create tpl file for field field--field-name.tpl.php. place it to your

if Field nameis: field_page_photos
then File name will: field--field-page-photos.tpl.php

clear cache.

paste below code to your tpl field file.

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>
  <div class="start-timer">START FLAG</div>
  <div class="starttime">
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
    <?php endforeach; ?>
  </div></div>
</div>
<script type="text/javascript" charset="utf-8">
(function($){$('.starttime').hide();$('.start-timer').click(function(){$('.starttime').show();});})(jQuery);
</script>
5
  • well it does solve one part of the problem....the timer starts on click but if i log in as another user then on click the timer appears but it has already count down the time since the earlier click by other logged in user
    – why
    Commented Mar 26, 2013 at 13:04
  • what i want is that each user would see a different timer( i understand its not an easy task but well...)..its something quite practical
    – why
    Commented Mar 26, 2013 at 13:09
  • different timer not possible. u need something other then Countdown Timer Field.
    – monymirza
    Commented Mar 26, 2013 at 14:03
  • and what may that be...any suggestions
    – user145078
    Commented Mar 26, 2013 at 19:24
  • Sounds like you are attaching the field to the node & not the user. You would probably want a reference to the node it's n also, and in the field let it have unlimited number, that way the user could have 2 of the same timers going and you could check if they have >3 and say they have to many. Anyhow attaching it to the user will fix it per user for 1 timer per user.
    – ransom bot
    Commented Mar 28, 2013 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.