1
tank1955
Developing custom template and hit a brick wall - Please help
  • 2008/2/20 4:07

  • tank1955

  • Module Developer

  • Posts: 276

  • Since: 2007/9/7 1


I am developing a calendar module and have hit a brick wall in trying to get a custom template working to display all the date entries.

XOOPS 2.0.16
PHP/MySQL 4.1.22
Apache Server / Linux

My template definition in the xoops_version.php file appears as follows:

// Templates
$modversion['templates'][1]['file'] = 'playdates_displaylistall.html';
$modversion['templates'][1]['description'] = '';

The template file resides in the module's templates directory. Here is a copy










<{section name=i loop=$dates_all}>
">




<{if $dates_all[i].info}>

<{else}>

<{/if}>

<{/section}>

<{$lang_date}>/<{$lang_time}> <{$lang_band}> <{$lang_venue}> <{$lang_location}> <{$lang_info}>
<{$dates_all[i].date}>  <{$dates_all[i].time}> <{$dates_all[i].band}> <{$dates_all[i].venue}> <{$dates_all[i].city}>, <{$dates_all[i].state}> <{$lang_more}>  


Finally the template is called from the show_list function in the index.php file. The following is the function excerpt from this file:

function show_list(){

global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsModule;

$xoopsOption['template_main'] = "playdates_displaylistall.html";
include(XOOPS_ROOT_PATH."/header.php");

$myts =& MyTextSanitizer::getInstance();

$xoopsTpl->assign('lang_title', _PD_TITLE);
$xoopsTpl->assign('lang_date', _PD_DATE);
$xoopsTpl->assign('lang_time', _PD_TIME);
$xoopsTpl->assign('lang_band', _PD_BAND);
$xoopsTpl->assign('lang_venue', _PD_VENUE);
$xoopsTpl->assign('lang_location', _PD_LOCATION);
$xoopsTpl->assign('lang_info', _PD_INFO);
$xoopsTpl->assign('lang_more', _PD_MORE2);

$now = time();
$start = mktime (0,0,0,date("m", $now), date("d", $now), date("Y", $now));

$result = $xoopsDB->queryF("SELECT id, date, band, venue, city, state, event, info FROM ".$xoopsDB->prefix()."_playdates WHERE pub='1' AND (date >= '$start') ORDER BY date");

$count = mysql_num_rows($result);

//echo $count;
//exit();

while($pd_date = $xoopsDB->fetcharray($result)) {
$playdates_array = array();
$playdates_array['id'] = $pd_date['id'];
$playdates_array['band'] = stripslashes($pd_date['band']);
$playdates_array['venue'] = stripslashes($pd_date['venue']);
$playdates_array['city'] = $pd_date['city'];
$playdates_array['state'] = $pd_date['state'];
$playdates_array['event'] = $pd_date['event'];
$playdates_array['info'] = $pd_date['info'];

$tempDate = $dateArray=explode(',',strftime("%Y,%m,%d,%I,%M,%p",$pd_date['date']));
$playdates_array['date'] = date('D M j Y', mktime(0, 0, 0, $tempDate[1], $tempDate[2], $tempDate[0]));
$playdates_array['time'] = $tempDate[3].":".$tempDate[4].strtolower($tempDate[5]);

$xoopsTpl->append('dates_all', $playdates_array);
}
}

include XOOPS_ROOT_PATH."/footer.php";

I have used the debug features with no resulting errors. The problem is nothing appears on the page. The link to where I am currently testing the module (I have named Play Dates) is http://www.tanksplace.com/modules/playdates . Thanks in advance for any help to resolve my dilemma.

2
tank1955
Re: Developing custom template and hit a brick wall - Please help
  • 2008/2/21 4:01

  • tank1955

  • Module Developer

  • Posts: 276

  • Since: 2007/9/7 1


I discovered the problem. I needed to declare xoopsOption as a global at the start of the showlist() function.

Login

Who's Online

159 user(s) are online (108 user(s) are browsing Support Forums)


Members: 0


Guests: 159


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits