plainblack.com
Username Password
search
Bookmark and Share

    

Calendar Template Help

User philadev
Date 1/11/2008 3:25 pm
Views 7530
Rating -1    Rate [
|
]
Previous · Next
User Message
philadev

I hope someone out there can help me:

I'm trying to create a semantic small month view for the calendar. The problem is that I keep getting an error:

Couldn't call method view on asset for url: offices/e/example/staging/calendar Root cause: HTML::Template->output() : fatal error in loop output : HTML::Template->output() : fatal error in loop output : HTML::Template::param() : attempt to set parameter 'events' with an array ref - parameter is not a TMPL_LOOP! at /data/wre/prereqs/perl/lib/site_perl/5.8.8/HTML/Template.pm line 2997

The real problem is I can't stop the problem loop and the loop and variable descriptions don't seem to match the variables and loop names in the templates (i.e. dayOfMonth is listed as the tmpl_var but dayMonth is the actual var etc...)

I plan to post a few calendar templates based on this to the Add Ons section so any help will hopefully benefit us all.

Here's the template:


<tmpl_if admin>
    <p><tmpl_var adminControls></p>
</tmpl_if>

<tmpl_if displayTitle>
    <h2><tmpl_var title></h2>
</tmpl_if>

<tmpl_if description>
    <tmpl_var description>
</tmpl_if>
<div class="calendar">
<ul class="calNav">
        <li><a href="<tmpl_var urlDay>">Day</a></li>
        <li><a href="<tmpl_var urlWeek>">Week</a></li>
        <li><a href="<tmpl_var urlMonth>">Month</a></li>
        <li><a href="<tmpl_var urlSearch>">Search</a></li>
</ul>
<ul class="calControls">
              <tmpl_if editor><li><a href="<tmpl_var urlAdd>">Add Event</a></li></tmpl_if>
             <li><a href="<tmpl_var urlPrint>">Print</a></li>
              <li><a href="<tmpl_var urlIcal>">iCal </a></li>
            <!--&bull; <a href="#">Subscribe</a>-->
</ul>


<ul class="yrMonthNav">
      <li><a href="<tmpl_var pagePrevUrl>" class="yearNavLast">&laquo; <tmpl_var pagePrevYear></a> &bull;</li>
        <tmpl_loop months><li class="monthLink<tmpl_if monthCurrent> current</tmpl_if>"><a href="<tmpl_var monthUrl>"><tmpl_var monthAbbr></a></li></tmpl_loop>
    <li>&bull; <a href="<tmpl_var pageNextUrl>" class="yearNavNext"><tmpl_var pageNextYear> &raquo;</a></li>
</ul>
         
         
<div class="calContainer"> 
<table cellspacing="0" cellpadding="0" class="mCal">

<thead>   
        <!-- day names -->
          <tr><th class="monthTitle" colspan="7"><tmpl_var monthName> <tmpl_var year></th></tr>
        <tr>
          <tmpl_loop dayNames><th><tmpl_var dayAbbr></th></tmpl_loop>
          </tr>
<thead>
<tbody>
        <!-- the grid -->
        <tmpl_loop weeks><tr>
        <tmpl_loop days><td class="<tmpl_if dayMonth><tmpl_if events><tmpl_unless dayCurrent>event <tmpl_else>curEvent </tmpl_unless><tmpl_else><tmpl_if dayCurrent>current </tmpl_if></tmpl_if><tmpl_else>nonDay </tmpl_if>">
            <tmpl_if dayMonth>
               <a class="number<tmpl_if events> moreButton</tmpl_if>" <tmpl_if events>id="event_<tmpl_var dayMonth>" onmouseover="return showEvents('overlay<tmpl_var dayMonth>');" </tmpl_if>href="<tmpl_var dayUrl>"><tmpl_var dayMonth></a>
             <!--/events-->
            </tmpl_if> <!--/day-->
        </td></tmpl_loop> <!--/days-->
        </tr></tmpl_loop>
 </tbody>
</table>
</div>
    <tmpl_loop weeks><tmpl_loop days><tmpl_if events>
      <div id="overlay<tmpl_var dayMonth>" class="moreDisplay">
         <div>
            <ul>
            <tmpl_loop events>
            <li><a href="<tmpl_var eventUrl>"><tmpl_var eventTitle></a><br/></li>
            </tmpl_loop>
         </ul>           
      </div>
   </div>
</tmpl_if></tmpl_loop></tmpl_loop>
</div>

 
Thanks - Nate 

--- (Edited on 1/11/2008 3:25 pm [GMT-0600] by philadev) ---



Back to Top
Rate [
|
]
 
 
colink

I've looked at this, and I'm pretty sure that this is due to your use of tmpl_if events, without really using events as a loop inside each if statement.  It's an issue with HTML::Template.

Here are a few suggestions to try:

  1. Put empty loops inside each tmpl_if and see if it helps
  2. Switch to a better templating system, like Template::Toolkit

--- (Edited on 1/11/2008 5:05 pm [GMT-0600] by colink) ---



Back to Top
Rate [
|
]
 
 
philadev

The empty loops did the trick.

Would you mind explaining a bit more about Template::Toolkit? I don't see the optioin and a site search doesn't reveal much.

Thanks.

--- (Edited on 1/14/2008 11:02 am [GMT-0600] by philadev) ---



Back to Top
Rate [
|
]
 
 
colink

Template::Toolkit is another templating engine.  WebGUI has the ability to use HTML::Template, HTML::Template::Expr, and Template::Toolkit as engines.

I'm surprised no one has made a wiki article about this already:

  1. Install Template::Toolkit
  2. In your webgui.conf file, add WebGUI::Asset::Template::TemplateToolkit to the list of templateParsers.
  3. Restart your web server.

The templating sytax is different, and the variable names are a little different due to the different syntax (use _ instead of .), but the templating language is much more powerful.

Those are the upsides. The downsides is that it may be slower than HTML::Template, and I haven't actually tested Template::Toolkit to see if it suffers from the same bug as  HTML::Template.  It may, and may have other bugs as well.

--- (Edited on 1/14/2008 11:58 am [GMT-0600] by colink) ---



Back to Top
Rate [
|
]
 
 
Klaus

Would you mind explaining a bit more about Template::Toolkit? I don't see the optioin and a site search doesn't reveal much.

You can use additional template engines in WebGUI. You have to install it, add it to the webgui.conf file for the site, restart WebGUI and then set the Template Type in the options for the style template. The default is HTML::Template

Klaus 

--- (Edited on 14-January-2008 19:08 [GMT+0100] by Klaus) ---



Back to Top
Rate [
|
]
 
 
philadev

Thank you both. I'm pretty suprised to find out that there is more than one template language available for use with WebGUI, opens up a whole new world really.

I'll look into to this.

 

Thanks again,

Nate 

--- (Edited on 1/14/2008 12:51 pm [GMT-0600] by philadev) ---



Back to Top
Rate [
|
]
 
 
Trex

I just had the exact same problem for the exact same reason! I was trying to create a mini-month calendar view, and was using the <tmpl_if events> condition without calling the loop within the condition. I wish I'd seen this thread before trying to figure out why my template was not working! I actually figured out the problem and solution on my own, but this thread would have saved me some time, if I'd found it sooner.

To help save others time and headaches, I've updated the main wiki page on the template language to include this information.

--- (Edited on 2010-03-13 11:35 pm [GMT-0600] by Trex) ---



Back to Top
Rate [
|
]
 
 
    



© 2018 Plain Black Corporation | All Rights Reserved