Hello,
I've seen this problem before with phplib templates.. And I've fixed
this problem before (on different code).. However for the life of me
right now I can't see what the heck is wrong with how I've structured
the template for this function and why I'm getting this error (is there
any way that this error could be more descriptive in future releases?)..
The problem seems to be with a block I am trying to insert into an
existing template. I can print a section name, but wan to list all of
the sub-sections.
So the template (be_section.tpl) is defined like this:
<!-- START OF TEMPLATED DISPLAY SECTION -->
<h2>{SECTION_TITLE}</h2>
{SECTION_BLERB}
{MODIFY} {NEW_ARTICLE}
<!-- BEGIN section_row
--><em>{SUB_SECTION_TITLE}<br>{SUB_SECTION_BLERB}</em><!-- END
section_row -->
<BR><hr align="left" width="50%" noshade>
<!-- END OF TEMPLATED DISPLAY SECTION -->
The function that I am using to call this template looks like the
following:
function getSection($ary) {
global $_PSL, $_BE;
// Template
$template = "printSection";
// Section Blocks
$this->template->set_block($template,"section_row","section_rows");
/*
* Call to _base layer for getting the Section stuff out the DB
*/
if(empty($ary['section'])) $ary['section'] = '0';
$section_ary = $this->extractSection($ary['section']);
# debug("Section::extractSections.section_ary", $section_ary);
if ($this->perm->have_perm("story,root")) {
$newArticle = "<a href=\"" . $_PSL['adminurl'] .
"/articleAdmin.php3?submit=newSection\">New Article</a>";
$modify = "<a href=\"" . $_PSL['adminurl'] .
"/articleAdmin.php3?submit=editSection§ionID=" .
$section_ary['sectionID'] . "\">Edit Section</a>";
$modify .= " <a href=\"" . $_PSL['adminurl'] .
"/articleAdmin.php3?submit=deleteSection§ionID=" .
$section_ary['sectionID'] . "\">Delete Section</a> ";
}
$this->template->set_var(array(
'SECTION_ID' => $section_ary['sectionID'],
'SECTION_URLNAME' => $section_ary['URLname'],
'SECTION_TITLE' => $section_ary['title'],
'SECTION_BLERB' => $section_ary['blerb'],
'MODIFY' => $modify,
'SNEW_ARTICLE' => $newArticle
));
$subSection_ary = $this->extractSubSection($section_ary['sectionID']);
if (is_array($subSection_ary)) {
for ($i = '0' ; $i < count($subSection_ary) ; $i++) {
# debug("Section::extractSubSections.subSection_ary",
$subSection_ary[$i]);
if ($this->perm->have_perm("story,root")) {
$modify = "<a href=\"" . $_PSL['adminurl'] .
"/articleAdmin.php3?submit=edit&articleID=" .
$articles_ary[$i]['articleID'] . "\">edit</a>";
$modify .= " <a href=\"" . $_PSL['adminurl'] .
"/articleAdmin.php3?submit=delete&articleID=" .
$articles_ary[$i]['articleID'] . "\">delete</a> ";
}
$this->template->set_var(array(
'SUB_SECTION_TITLE' => $subSection_ary[$i]['title'],
'SUB_SECTION_BLERB' => $subSection_ary[$i]['blerb'],
'SUB_MODIFY' => $modify
));
$this->template->parse("section_rows","section_row",true);
}
}
$this->template->parse('OUT', $template);
$thesection = $this->template->get('OUT');
return $thesection;
}
The debugging info outputs the appropriate arrays, so that's working..
Also, if there are three subsections in a section I get three copies of
this error:
Template Error: loadfile: section_row is not a valid handle.
Template Error: subst: unable to load section_row.
I get the results of the results from the main template variables just
fine, and I do get the last result from the array in the block I'm
having trouble with outputed..
I've just got to get rid of the errors and output all of the variables
in the block..
So what the heck am I doing wrong? Oh yea, forgot to mention that
printSection is defined above that?
$template_ary = array(
"printArticle" => "be_article.tpl",
"printSection" => "be_section.tpl",
"newarticle" => "articleNew.tpl",
"indexarticle" => "articleIndex.tpl"
);
Nathan, some of this code might look vaguely familiar to you as it's
based on phpSlash..
Also, I get this in digest mode, so if anyone does have any suggestions
on why I'm getting this annoying error, please cc mi...@op...
Mike
--
Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca
Open Source Web Applications for Social Change
New Site Launched: http://www.patmartin.org/
War is a poor chisel to carve out tomorrows. ML King, Jr.
|