On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi

    Is it possible to remove the hour:minutes of the date from the a date TV?

    See attached image. I want to remove the 7:44 box.

    Thanks
    • I create a new date TV without hour:minutes

      <input id="tv{$tv->id}" type="text" class="datefield"
      	value="{$tv->value}" name="tv{$tv->id}"
      	onblur="MODx.fireResourceFormChange();"/>
      
      <script type="text/javascript">
      // <![CDATA[
      {literal}
      MODx.load({
      {/literal}
      xtype: 'datefield'
          ,applyTo: 'tv{$tv->id}'
          ,width: '97%'
          ,format: MODx.config.manager_date_format
          ,name: 'tv{$tv->id}'
          ,dateWidth: 120
          ,allowBlank: true
          ,value: '{$tv->value}'
      {literal}
          ,listeners: { 'change': { fn:MODx.fireResourceFormChange, scope:this}}
      });
      {/literal}
      // ]]>
      </script>
      


      if you need a detail for create new tv, ask me.

      Laurent
      • Hi Laurent,

        I’d like to see how you do it.

        Found this as well
        http://rtfm.modx.com/display/revolution20/Adding+a+Custom+TV+Input+Type

        Thank you
        • i’ll explain tomorrow.
          it’s easy smiley

          good night
          • Have a good night!
            • hi,

              for create a TV without time

              duplicate date.php in

              /core/model/modx/processors/element/tv/renders/mgr/input/
              choose the name : ex dateWithoutTime

              in the code change those lines :
              if ($v != '' && $v != '0' && $v != '0000-00-00 00:00:00') {
                  $v = strftime('%Y-%m-%d %H:%M:%S',strtotime($v));
              }
              

              by
              if ($v != '' && $v != '0' && $v != '00-00-0000') {
                  $v = strftime('%d-%m-%Y',strtotime($v));
              }
              


              and change this last line
              return $this->xpdo->smarty->fetch('element/tv/renders/input/date.tpl');
              

              by
              return $this->xpdo->smarty->fetch('element/tv/renders/input/dateWithoutTime.tpl');
              




              and in this folder

              /manager/templates/default/element/tv/renders/input/

              duplicate date.tpl with this name dateWithoutTime

              open dateWithoutTime.tpl

              and change
              <script type="text/javascript">
              // <![CDATA[
              {literal}
              MODx.load({
              {/literal}
                  xtype: 'xdatetime'
                  ,applyTo: 'tv{$tv->id}'
                  ,width: '97%'
                  ,name: 'tv{$tv->id}'
                  ,dateFormat: MODx.config.manager_date_format
                  ,timeFormat: MODx.config.manager_time_format
                  ,dateWidth: 120
                  ,timeWidth: 120
                  ,allowBlank: true
                  ,value: '{$tv->value}'
              {literal}
                  ,listeners: { 'change': { fn:MODx.fireResourceFormChange, scope:this}}
              });
              {/literal}
              // ]]>
              </script>
              

              by
              <script type="text/javascript">
              // <![CDATA[
              {literal}
              MODx.load({
              {/literal}
                  xtype: 'datefield'
                  ,applyTo: 'tv{$tv->id}'
                  ,width: '97%'
                  ,format: MODx.config.manager_date_format
                  ,name: 'tv{$tv->id}'
                  ,dateWidth: 120
                  ,allowBlank: true
                  ,value: '{$tv->value}'
              {literal}
                  ,listeners: { 'change': { fn:MODx.fireResourceFormChange, scope:this}}
              });
              {/literal}
              // ]]>
              </script>
              



              you just create a new TV date without time wink
              • Almost there,

                I get this with your code - see image.

                Anyway I can control the name of the TV dateWithoutFormat -> Date Without Time?

                Thanks
                • yes i can choose other name
                  careful to change the name in the code

                  me i don’t use the output date. I left the default value


                  • That’s the thing, I have no idea where I can change the name. Is it another file or code I should add to a file?

                    Btw, have you seen the first image? The date without time doesn’t look too good. It’s missing the output section

                    Thanks
                    • excuse me, I forgot to tell you to change this line
                      in dateWithoutTime.tpl

                      <input id="tv{$tv->id}" type="hidden" class="datefield"
                      value="{$tv->value}" name="tv{$tv->id}"
                      onblur="MODx.fireResourceFormChange();"/>

                      to :

                      <input id="tv{$tv->id}" type="text" class="datefield"
                      value="{$tv->value}" name="tv{$tv->id}"
                      onblur="MODx.fireResourceFormChange();"/>