Welcome Guest, Not a member yet? Register   Sign In
Another Calendar Question
#1

[eluser]herbageonion[/eluser]
Hi, I was wondering if its possible to alter the calendar template to show days in a more linear, horizontal layout. See attached file for an example of what I'm trying to achieve.
#2

[eluser]sophistry[/eluser]
Go to the bottom of the calendar manual page which shows you how to structure a calendar template.

The default template is a standard table but you should be able to manipulate it to get your result.

Once you get something working, please be sure to post it back to the site somewhere - a wiki page or an IgnitedCode thread would be fine.
#3

[eluser]herbageonion[/eluser]
Hi,

I've been playing around with the template but I cant get the layout I want, does anyone have any suggestions? I'll need some help on this one.

Cheers
#4

[eluser]sophistry[/eluser]
Well, how far did you get? Posting code always helps.
#5

[eluser]herbageonion[/eluser]
I've got the linear look I want but I cant get each day to have the right day of the week.

Code:
$prefs['template']  = '
  
   {table_open}<table border="0" cellpadding="0" cellspacing="1">{/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}{/week_row_start}
   {week_day_cell}{week_day}{/week_day_cell}
   {week_row_end}{/week_row_end}
    
   {cal_row_start}<tr>{/cal_row_start}
   {cal_cell_start}<td class="startcell"><tr><td>{/cal_cell_start}
    
   {cal_cell_content}
   <a href="">{day}</a>
   <td>{content}</td>
   <td>Waiting List</td>
   {/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></tr></td>{/cal_cell_end}
   {cal_row_end}</tr>{/cal_row_end}
    
   {table_close}</table>{/table_close}
';

I'm not sure its possible to do what I want here, do you have any suggestions?
#6

[eluser]sophistry[/eluser]
Can you post the screenshot of what this looks like? Also, there are extra <<< and >>> in the heading area of the template. They may cause problems.

it sounds like {week_day} is what you are looking to show but I can't really understand fully what you are lacking.
#7

[eluser]herbageonion[/eluser]
I haven't done any styling to it yet just trying to get the basic structure down but you can have a look anyway...
#8

[eluser]sophistry[/eluser]
Ok. I actually just looked at the calendar code and it turns out you are up against a limitation of the calendar class architecture: it doesn't support applying daynames to the {day} template variable. It only applies day names in the typical monthly calendar way with a row at the top.

EDIT: added link here
Yet another reason why the calendar class needs a revamping.

Anyway, it wouldn't be hard to hack in a {day_of_week_name} template variable. Just add it into all the places where {day} is called for in the calendar class.

An even quicker way would be to simply hard code your dayname to become part of the big $out string that gets concatenated in the generate() method.

EDITED to make it apply to both cells with and without content:
See line 219... I marked my UNTESTED HACK insert. please let me know if this works or if it doesn't then post what does.
Code:
// INSERT
// get the day name for the current day
$day_name = date('l', strtotime("$month/$day/$year"));
// hack whatever CSS or HTML you want here
$out .= "<span>$day_name</span>";
// END INSERT

if (isset($data[$day]))
  {
   // Cells with content
   $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];  
   $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
  }
  else
  {
   // Cells with no content
   $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
   $out .= str_replace('{day}', $day, $temp);
  }

EDIT: if you do use this HACK you can do it in a nicer way by extending the base calendar class using MY_ prefix and overriding the generate() method.
#9

[eluser]herbageonion[/eluser]
Hey sophistry, thanks for your help so far. Unfortunately, that didn't actually make a change.

I'm using the calendar class in another controller and I didn't want to hack the original, so I created a copy called calendar_hacked and I'm using that instead. I tried inserting what you gave me but no luck, it just gave me back what I've been getting all along.

Any more ideas?

Thanks again for your help.
#10

[eluser]sophistry[/eluser]
oops. forgot to add it to the "cells with no content" section of the if statement too.

or, you could just put this code outside of the if statement so as not to have duplicate code.

i edited the above code to do just that.

that should do it.




Theme © iAndrew 2016 - Forum software by © MyBB