We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22972
    • 4 Posts
    Hi

    I have been implementing gig calendar using Modx.
    I have created container for shows, it looks like this:
    Upcoming shows:
    
    [!Ditto? &startID=`63` &filter=tvShowTime,[[mytimesnip]],6 &sortBy=`ShowTime` &sortDir=`ASC` &summarize=`5` &total=`5`&tpl=`showsummary` &paginateAlwaysShowLinks=`1`!]
    Shows in the past:
    
    [!Ditto? &startID=`63` &filter=tvShowTime,[[mytimesnip]],5 &sortDir=`ASC` &summarize=`5` &total=`5`&tpl=`showsummary`!]


    Mytimesnio just returns current time.
    ShowTime is template variable which contains date for gig. It’s type is date and widget is unixtime.
    Problem is that I have to make post page where user can insert information for show and also this show time. I have this kind of posting page:
    [!NewsEditor? &folder=`63` &clearcache=`1` &formtpl=`Showtimetpl`!]

    Showtimetpl is like this:
    <form name="NewsEditor" method="post" action="[~[*id*]~]">
    <input name="NewsEditorForm" type="hidden" value="on" />
    <input name="editid" type="hidden" value="[+editid+]" />
    Page title:<br /><input name="pagetitle" type="text" size="40" value="[+pagetitle+]" /><br />
    <p>Enter place for show <br />
    <input name="longtitle" type="text" size="40" value="[+longtitle+]" /></p>
    <p>More info about show <br />
    <input name="content" type="text" size="40" value="[+content+]" /></p>
    <p>Date for show (Select opens date selection tool) <br />
    
    <input name="tvShowTime"> 
    <input type=button value="select" onclick="displayDatePicker('tvShowTime', false, 'dmy', '-');">
    
    
    
    <br />
    <input name="send" type="submit" value="Submit" />
    </form>
    

    I have tried several things for inserting showtime variable, but no success. How I can insert this variable from blog form? If I post gig from form and edit date from manager UI (which have date picker) everything works ok. But I need to have this datepicker in web UI because web users must be able to submit new shows.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There are a number of date picker scripts.

      http://www.google.co.il/#hl=en&source=hp&q=mootools+date+picker&meta=&aq=0&oq=mootools+date+pic&fp=65f4fc76eed91425

      Here’s a real beauty! http://www.frequency-decoder.com/demo/date-picker-v2/
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22972
        • 4 Posts
        I tried one datepicker (http://www.styledisplay.com/mootoolsdatepicker/):
        <form name="NewsEditor" method="post" action="[~[*id*]~]">
        <input name="NewsEditorForm" type="hidden" value="on" />
        <input name="editid" type="hidden" value="[+editid+]" />
        Page title:<br /><input name="pagetitle" type="text" size="40" value="[+pagetitle+]" /><br />
        <p>Enter place for show <br />
        <input name="longtitle" type="text" size="40" value="[+longtitle+]" /></p>
        <p>More info about show <br />
        <input name="content" type="text" size="40" value="[+content+]" /></p>
        <p>Date for show (Select opens date selection tool) <br />
        <script type="text/javascript" src="/datepicker/DatePicker.js"></script>
        
        <script type="text/javascript">
        
        // The following should be put in your external js file,
        // with the rest of your ondomready actions.
        
        window.addEvent('domready', function(){
        
        	$$('input.DatePicker').each( function(el){
        		new DatePicker(el);
        	});
        
        });
        
        
        </script>
        <p>
        		<label for="birthday">default calendar</label>
        		<input id="tvShowTime" name="tvShowTime" type="text" class="DatePicker" tabindex="1" value="10/24/2016" />
        	</p>
        
        <br />
        <input name="send" type="submit" value="Submit" />
        </form>

        But it does not work, I think datepicker works ok, but value is not saved to template variable. Do I use template variable wrong? Or should I do some conversion to unixtime format? There was one timepicker which gives unixtime format directly, but it needs mootools 1.2 and I have 1.1 (http://www.monkeyphysics.com/mootools/script/2/datepicker). What is format that this kind of normal datepicker outputs, is it same as I see in input screen:
        08/01/2009
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The datepicker that MODx uses puts out exactly what you see in the text field after selecting a date from the javascript widget.

          The Publish and Unpublish dates are converted to a Unix timestamp before being inserted into the database.

          However, a Date-type TV is simply stored as a string in the form the datepicker puts out. It usually needs to be converted to a UNIX timestamp before it can be used in a snippet. The TV "Unixtime" output widget uses the mktime function if it’s a standard MySQL date format, and strtotime otherwise.

          http://il.php.net/mktime
          http://il.php.net/strtotime
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 22972
            • 4 Posts
            I think I must have something wrong in usage of TV in my form. I added simple text TV named ’Show’ and tried that also, no success. I cannot save anything to this variable either from my own posting form:
            <form name="NewsEditor" method="post" action="[~[*id*]~]">
            <input name="NewsEditorForm" type="hidden" value="on" />
            <input name="editid" type="hidden" value="[+editid+]" />
            Page title:<br /><input name="pagetitle" type="text" size="40" value="[+pagetitle+]" /><br />
            <p>Enter place for show <br />
            <input name="longtitle" type="text" size="40" value="[+longtitle+]" /></p>
            <p>More info about show <br />
            <input name="content" type="text" size="40" value="[+content+]" /></p>
            <p>Date for show (Select opens date selection tool) <br />
            <script type="text/javascript" src="/datepicker/DatePicker.js"></script>
            
            <script type="text/javascript">
            
            // The following should be put in your external js file,
            // with the rest of your ondomready actions.
            
            window.addEvent('domready', function(){
            
            	$$('input.DatePicker').each( function(el){
            		new DatePicker(el);
            	});
            
            });
            
            
            </script>
            <p>
            		<label for="birthday">default calendar</label>
            		<input id="tvShowTime" name="tvShowTime" type="text" class="DatePicker" tabindex="1" value="10/24/2016" alt="{format:'mm-dd-yyyy'}" />
            	</p>
            <P><INPUT TYPE=text NAME="tvShow" SIZE=8 MAXLENGTH=8></P>
            
            <br />
            <input name="send" type="submit" value="Submit" />
            </form>
            


            Quote from: sottwell at Aug 29, 2009, 02:35 AM

            The datepicker that MODx uses puts out exactly what you see in the text field after selecting a date from the javascript widget.

            The Publish and Unpublish dates are converted to a Unix timestamp before being inserted into the database.

            However, a Date-type TV is simply stored as a string in the form the datepicker puts out. It usually needs to be converted to a UNIX timestamp before it can be used in a snippet. The TV "Unixtime" output widget uses the mktime function if it’s a standard MySQL date format, and strtotime otherwise.

            http://il.php.net/mktime
            http://il.php.net/strtotime
            Do you mean that I just need to have my date picker using MySQL date format (YYYY-MM-DD HH:MM:SS) and then unixtime widget in TV handles that variable is oputputted as unix time stamp? Actually datepicker inside ModX manager uses that format and tvShowTime is saved correctly.
            I actually checked manager page source code:
            <input class="plugin-datetimepicker-field-3" id="tvShowTime" name="tvShowTime" value="" onblur="documentDirty=true;" type="hidden">	<table width="250" border="0" cellpadding="0" cellspacing="0">	  <tbody><tr>		<td style="border: 1px solid rgb(128, 128, 128);" width="160"><span id="tvShowTime_show" class="plugin-datetimepicker-show-3"> (not set)</span> </td>		<td> 			<a class="plugin-datetimepicker-trigger-3" onmouseover="window.status='Select a date'; return true;" onmouseout="window.status=''; return true;" style="cursor: pointer;"><img src="media/style/MODxLight//images/icons/cal.gif" width="16" border="0" height="16"></a>			<a onclick="document.forms['mutate'].elements['tvShowTime'].value='';document.forms['mutate'].elements['tvShowTime'].onblur();document.getElementById('tvShowTime_show').innerHTML='(not set)'; return true;" onmouseover="window.status='clear the date'; return true;" onmouseout="window.status=''; return true;" style="cursor: pointer;"><img src="media/style/MODxLight//images/icons/cal_nodate.gif" alt="No date" width="16" border="0" height="16"></a>		</td>	  </tr>    </tbody></table><script type="text/javascript">	var calShowTime = new calendar1(document.forms['mutate'].elements['tvShowTime'], document.getElementById("tvShowTime_show"));   calShowTime.path="http://www.insaneaffection.com/manager/media/";	calShowTime.year_scroll = true;   calShowTime.time_comp = true;</script>

            <span class="warning">Show</span>
            			<br><span class="comment"></span></td>
            			<td style="position: relative;" valign="top">
            			<input id="tvShow" name="tvShow" value="" tvtype="text" onchange="documentDirty=true;" style="width: 300px;" type="text">
            

            And both of these are working but I don’t know why my own form isn’t?
            Both TVs have public access.