We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8619
    • 229 Posts
    Getting a parse error on DittoCal:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: file_get_contents(http://www.ejcross.com/blog_json_output) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404
    Error type/ Nr.: Warning - 2
    File: /home/ejcrossc/public_html/manager/includes/document.parser.class.inc.php(748) : eval()’d code
    Line: 126

    Parser timing
    MySQL: 0.0109 s (7 Requests)
    PHP: 1.5366 s
    Total: 1.5475 s

    I am running 0.9.5 with Ditto 2.0.2 and DittoCal 1.2 with PHP 5.1.6 and mySQL 5.0.27.

    DittoCal is in a template like this: [!DittoCal? &calSource=`http://www.ejcross.com/blog_json_output` &dayNameLength=`1` &debug=`1`!] and I’m not getting any output. Trying to go directly to the json_output page via URL also throws the parse errors.

    Not sure what I’m missing, can anyone help?
      • 17673
      • 194 Posts
      Is the template for the Json file set to blank ?
        ----------------------------------------------------------
        http://www.linkedin.com/in/lucapost/
        http://www.twitter.com/lukwe/
        ----------------------------------------------------------
        • 8619
        • 229 Posts
        Yep, template file is set to blank, I can see the output in the preview window of the manager, but nothing else from the front end of it, including the site itself.
          • 17717
          • 433 Posts
          For improved accessibility, is there any way to add a title tag to the next and previous links, something that could be read out loud in screen readers.

          Thanks
          Lee
            http://www.blend.uk.com | Web Design by Blend
            • 17673
            • 194 Posts
            This is an easy hack of the PHP Calendar HTML output in DittoCal!
            Last week I just added various accessibility-important elements into my DittoCal HTML table (summary, title tags, column headers/ids -see below); to do it right though DittoCall should be extended to use language files (and an extra parameter for output language selection), and Keith Devens (i.e. the PHPCalendar’s creator) should also be kept informed/involved... I don’t think using the locale setting of the web-server is very useful for a multi-language site.

            # PHP Calendar (version 2.3), written by Keith Devens
            # http://keithdevens.com/software/php_calendar
            #  see example at http://keithdevens.com/weblog
            # License: http://keithdevens.com/software/license
            
            function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
            	$first_of_month = gmmktime(0,0,0,$month,1,$year);
            	#remember that mktime will automatically correct if invalid dates are entered
            	# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
            	# this provides a built in "rounding" feature to generate_calendar()
            
            	$day_names = array(); #generate all the day names according to the current locale
            	for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
            		$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
            
            	list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
            	$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
            	$title   = htmlentities(ucfirst($month_name)).' '.$year;  #note that some locales don't capitalize month and day names
            
            	#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
            	@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
            	if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'" id="calendar-prev" rel="nofollow" title="previous month">'.$p.'</a>' : $p).'</span> ';
            	if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'" id="calendar-next" rel="nofollow" title="next month">'.$n.'</a>' : $n).'</span>';
            	$calendar = '<table class="calendar" cellspacing="0" cellpadding="0" summary="monthly calendar to locate articles by date of pubblication">'."\n".
            		'<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'" rel="nofollow" title="view all articles for the current month">'.$title.'</a>' : $title).$n."</caption>\n<tr>";
            
            	if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
            		#if day_name_length is >3, the full name of the day will be printed
            		foreach($day_names as $d)
            			$calendar .= '<th abbr="'.htmlentities($d).'" scope="col" id="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
            		$calendar .= "</tr>\n<tr>";
            	}
            
            	if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
            	for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
            		if($weekday == 7){
            			$weekday   = 0; #start a new week
            			$calendar .= "</tr>\n<tr>";
            		}
            		if(isset($days[$day]) and is_array($days[$day])){
            			@list($link, $classes, $title, $content) = $days[$day];
            			if(is_null($content))  $content  = $day;
            			$calendar .= '<td headers="'.htmlentities($day_names[$weekday]).'"'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
            				($link ? '<a href="'.htmlspecialchars($link).'" title="list all articles posted on this day" rel="nofollow">'.$content.'</a>' : $content).'</td>';
            		}
            		else $calendar .= '<td headers="'.htmlentities($day_names[$weekday]).'">'.$day.'</td>';
            	}
            	if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
            
            	return $calendar."</tr>\n</table>\n";
            }
            

              ----------------------------------------------------------
              http://www.linkedin.com/in/lucapost/
              http://www.twitter.com/lukwe/
              ----------------------------------------------------------
              • 17717
              • 433 Posts
              Thanks for that, I skimmed through the snippet, obviously I missed the generated code. I agree that the original developer should be updated on improvements.

              Thanks
                http://www.blend.uk.com | Web Design by Blend
                • 23491 ☆ A M B ☆
                • 1,056 Posts
                Unfortunately experiencing the same thing on our end:

                MODx 096 (stable)
                DittoCal 1.2
                Ditto 2.0.2

                Default month: December 1969 sad
                Calendar, but NO links sad

                My "blog json output" sample renders the JSON object just fine, complete with my two sample entries:

                {
                 "title":"blog json output",
                 "link":"http://www.mydomain.com/blog_json_output.html",
                 "description":"",
                 "language":"en",
                 "copyright":"Sitename Goes here",
                 "ttl":"120",
                 "entries":[
                	{
                	 "title":"Another Calendar Item",
                	 "link":"http://www.mydomain.com/secure/calendar/another_calendar_item.html",
                	 "date":"1181024138",
                	 "guid":"http://www.mydomain.com/secure/calendar/another_calendar_item.html",
                	 "author":"John doe",
                	 "description":"",
                	 "introtext":"This is another Calendar Item to see what is up with the date and why no link is showing...",
                	},
                	{
                	 "title":"First Calendar Item",
                	 "link":"http://www.mydomain.com/secure/calendar/first_calendar_item.html",
                	 "date":"1180940590",
                	 "guid":"http://www.mydomain.com/secure/calendar/first_calendar_item.html",
                	 "author":"John doe",
                	 "description":"test desc",
                	 "introtext":"test intro",
                	}
                 ]
                }
                



                However, once parsed, it’s like it’s dropping the entries huh No wonder I am not seeing any links on the Calendar, right?

                Output of
                $json->decode($source);

                Notice how there are no entries?

                stdClass Object ( [title] => blog json output [link] => http://www.mydomain.com/blog_json_output.html [description] => [language] => en [copyright] => Sitename Goes Here [ttl] => 120 [entries] => Array ( ) )

                When cal_month and cal_year are NOT present, this is the code that is to determine the default date, based on the most recent entry:

                } else {
                $timestamp = getDate($postData->entries[0]->date);
                $filterMonth = $timestamp["mon"];
                $filterYear = $timestamp["year"];
                }

                however, this is the output I get:

                Array
                (
                    [seconds] => 0
                    [minutes] => 0
                    [hours] => 16
                    [mday] => 31
                    [wday] => 3
                    [mon] => 12
                    [year] => 1969
                    [yday] => 364
                    [weekday] => Wednesday
                    [month] => December
                    [0] => 0
                )
                


                What gives w/ the 1969? probably a result of missing entries in the parsed JSON sad

                Update:
                It appears that the entries show up when I hit my "blog json output" test link directly from my browser, but when retrieving via CURL, I don’t get the entries!

                This is the result from the CURL (default usage is w/ file_get_contents), but disabled on this host:

                {
                "title":"blog json output",
                "link":"http://www.mydomain.com/blog_json_output.html",
                "description":"",
                "language":"en",
                "copyright":"My Site Name",
                "ttl":"120",
                "entries":[

                ]
                }

                This appears to be the source behind missing links and the 1969 issue...

                Finally! How could I be so blind wink The Calendar section is protected behind Web Security. Since the CURL call doesn’t pass the authentication, it never returns the entries. I’ll have to see if Ditto offers any options...

                In summary, does anyone know if DittoCal can be used in coordination with Web User Security??

                I am trying to pass
                &hidePrivate=`0`
                in my Ditto snippet call, but am not having any luck...
                  Mike Reid - www.pixelchutes.com
                  MODx Ambassador / Contributor
                  [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                  ________________________________
                  Where every pixel matters.
                  • 15987
                  • 786 Posts
                  It actually looks like you just need to get the date in the correct format.

                  your dates look like this: "date":"1181024138",

                  I can’t remember what the exact format should be, but its in the instructions/example I think.
                    • 23491 ☆ A M B ☆
                    • 1,056 Posts
                    Quote from: kylej at Jun 05, 2007, 08:13 PM

                    It actually looks like you just need to get the date in the correct format.

                    your dates look like this: "date":"1181024138",

                    I can’t remember what the exact format should be, but its in the instructions/example I think.

                    Actually, turns out that the copy of Ditto 2.0.2 doesn’t have the hidePrivate stuff active yet. The copy in the SVN does though, and upon installing 2.1BETA (which is working Great! so far wink ) the calendar worked instantly. Perfect timing, too, because this way I can keep the pages themselves secure but still access them.

                    Dates, although in unix_timestamp form, are coming through as expected wink

                    Is there a solution yet for multiple events on the same day? I was trying to get the &landing stuff working, but wasn’t having much luck. Also, I am not completely sure this is even the solution I am looking for anyway. I’ll have to read up on what &landing is for again and how to use. Possibly I will try again now that the DittoCal is receiving the proper JSON object.
                      Mike Reid - www.pixelchutes.com
                      MODx Ambassador / Contributor
                      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                      ________________________________
                      Where every pixel matters.
                      • 15987
                      • 786 Posts
                      no, no solution for multiple events on the same day. I will keep that in mind when I have time to work on this snippet.