Need PHP / Smarty Help on simple calendar

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jbradley04
Forum Newbie
Posts: 1
Joined: Sat Sep 25, 2010 12:31 pm

Need PHP / Smarty Help on simple calendar

Post by jbradley04 »

Hello,
I am trying to take a calendar script and use it on my site that uses Smarty templates. I have gotten all of it to work minus one spot!
I am having trouble trying to get the code below to output what I want in Smarty...
I have tried many things but to no avail!
Any help would be appreciated! Thanks!!
Obviously I want the html output from these PHP calls but I cant figure it out!
Thanks for your help!
Code:

Code: Select all

for($i=0; $i< $total_rows; $i++)
            {
                for($j=0; $j<7;$j++)
                {
                    $day++;                   
                   
                    if($day>0 && $day<=$total_days_of_current_month)
                    {
                        //YYYY-MM-DD date format
                        $date_form = "$current_year/$current_month/$day";
                       
                        echo  '<td';
                       
                        //check if the date is today
                        if($date_form == $today)
                        {
                            echo ' class="today"';
                        }
                       
                        //check if any event stored for the date
                        if(array_key_exists($day,$events))
                        {
                            //adding the date_has_event class to the <td> and close it
                            echo ' class="date_has_event"> '.$day;
                           
                            //adding the eventTitle and eventContent wrapped inside <span> & <li> to <ul>
                            echo '<div class="events"><ul>'.$events[$day].'</ul></div>';
                        }
                        else
                        {
                            //if there is not event on that date then just close the <td> tag
                            echo '> '.$day;
                        }
                       
                        echo "</td>";
                    }
                    else
                    {
                        //showing empty cells in the first and last row
                        echo '<td class="padding">&nbsp;</td>';
                    }
                }
                echo "</tr><tr>";
            }
Post Reply