Welcome Guest, Not a member yet? Register   Sign In
Calendar Class Problem
#11

[eluser]Dam1an[/eluser]
[quote author="bargainph" date="1242206955"]I envy your free time Smile[/quote]

It literally took just a few minutes, and if you dare look at the code, you'll see why
#12

[eluser]Thorpe Obazee[/eluser]
I didn't download the code. I'm at work during this time.

I see what you mean Smile
#13

[eluser]TheFuzzy0ne[/eluser]
I should also point out that the rewritten class doesn't actually extend the core as such, but rather replaces it. I'm going to spend a little time rewriting it for you.
#14

[eluser]TheFuzzy0ne[/eluser]
Here my way of doing it. It doesn't require any extending of the class, it's all done through a little bit of CSS and a template. You're welcome to export it into a function if you want to re-use the code.

./system/application/controllers/cal.php
Code:
<?php

class Cal extends Controller
{
    function Cal()
    {
        parent::Controller();
    }
    
    function index()
    {
        $this->load->library('calendar');
        
        $template = $this->calendar->default_template();
        $config['template'] = '

           {table_open}<table class="calendar" border="0" cellpadding="0" cellspacing="0">{/table_open}
        
           {heading_row_start}<tr>{/heading_row_start}
        
           {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
           {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
           {heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}
        
           {heading_row_end}</tr>{/heading_row_end}
        
           {week_row_start}<tr>{/week_row_start}
           {week_day_cell}<td>{week_day}</td>{/week_day_cell}
           {week_row_end}</tr>{/week_row_end}
        
           {cal_row_start}<tr>{/cal_row_start}
           {cal_cell_start}<td>{/cal_cell_start}
        
           {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content}
           {cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today}
        
           {cal_cell_no_content}{day}{/cal_cell_no_content}
           {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}
        
           {cal_cell_blank}&nbsp;{/cal_cell_blank}
        
           {cal_cell_end}</td>{/cal_cell_end}
           {cal_row_end}</tr>{/cal_row_end}
        
           {table_close}</table>{/table_close}
        ';
        
        $this->calendar->initialize($config);
        
        $this->load->vars(array(
                'cal1' => $this->calendar->generate(2009, 5, 13),
                'cal2' => $this->calendar->generate(2009, 6)
            ));
        $this->load->view('cal');
    }
}

./system/application/views/cal.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Double Calendar&lt;/title&gt;
        &lt;style type="text/css"&gt;
            table.calendar {
                float: left;
                margin: 3px;
            }
            table.calendar td {
                padding: 3px;
            }
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <div>
            &lt;?php echo $cal1; ?&gt;
            &lt;?php echo $cal2; ?&gt;
        </div>
        <div>
            &lt;!-- Add your next and prev links here --&gt;
        </div>
    &lt;/body&gt;
&lt;/html&gt;

It needs a bit of tweaking as I don't know what you wanted it to look like, but hopefully, that shouldn't be too difficult.
#15

[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1242212139"]I should also point out that the rewritten class doesn't actually extend the core as such, but rather replaces it. I'm going to spend a little time rewriting it for you.[/quote]

That is correct, as I just made a copy in application/libraries
(Then again, this was really more a proof of concept)

@Fuzzy: Your solution looks interesting, will look in a bit more detail to see what you're actually goin
#16

[eluser]Thorpe Obazee[/eluser]
I kind of modified the Calendaring class template too but still I needed to extend it for the reason that it's much more manageable since I used it as an Calendar Application+Event management system.
#17

[eluser]kostodo[/eluser]
I will give your code a try later on today! Thanks
#18

[eluser]TheFuzzy0ne[/eluser]
Sorry, Dam1an. I don't know what I was thinking. What I meant to say was not to edit the original file, but rather put it in ./system/application/libraries instead.
#19

[eluser]Dam1an[/eluser]
I know what you meant (and I didn't take it personally) Smile
#20

[eluser]Thorpe Obazee[/eluser]
hugs Smile




Theme © iAndrew 2016 - Forum software by © MyBB