We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    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
      • 17422
      • 225 Posts
      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
        • 5340
        • 1,624 Posts
        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
          • 17422
          • 225 Posts
          i’ll explain tomorrow.
          it’s easy smiley

          good night
            • 5340
            • 1,624 Posts
            Have a good night!
              • 17422
              • 225 Posts
              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
                • 5340
                • 1,624 Posts
                Almost there,

                I get this with your code - see image.

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

                Thanks
                  • 17422
                  • 225 Posts
                  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


                    • 5340
                    • 1,624 Posts
                    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
                      • 17422
                      • 225 Posts
                      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();"/>