On Mon, 27 Jan 2003, Eero af Heurlin wrote:

> >
> > [*] = I don't remember if <[code-init]> is nadmin specific or general
> >       for any midgard app. I think it's general for all midgard though? 
> > 
> 
> There a few "magic" elements (style- or page-) that are called in the 
> following order by midgard-root.php
> 
> <[code-compat]>
> <[code-global]>
> <[code-init]>
> <[ROOT]>
> 
> The <(title)> is not called automatically but is filled with the title 
> string of current page, <(content)> is not called automatically but is 
> filled with the content of the currect page.

Just so everyone is on the same page, What I'm trying to do is generate a 
404 status (which will hopefully force APache to serve up my 
ErrorDocument) if specific conditions aren't met.

I have some code that maps URLs of active pages to code snippets or
articles depending on certain criteria. Instead of doing this in code-init
where I'd have to make sure I put a code-init element on the root page of
each site, I included this file from midgard-root.php, before the
code-compat, code-global or code-init page elements are called. It should
work, but it isn't. (Well, the part that maps URLs to snippets or articles
works perfectly, but it doesn't behave properly when all of the checks are
completed and $JTN_notfound is still set to TRUE. Theoretically, it should
work. This code is called immediately after midgard.so is loaded and the
$midgard variable is populated, and before anything else happens in
midgard-root.php. This code is executed for any website in a sitegroup 
other than SG0.

<?

$JTN_host=mgd_get_host($midgard->host);

if ($JTN_host->sitegroup!=0)
{
  $JTN_pagetitle="";
  $JTN_is_article=false;
  $JTN_is_default_page=false;
  $JTN_is_snippet=false;
  $JTN_notfound=true;
    
  $temp1=mgd_get_page($JTN_host->root);
  $JTN_snippetdir=$temp1->parameter("system","snippet_dir");

  $temp1=mgd_get_page($midgard->page);
  $JTN_newsdir=$temp1->parameter("system","is_news_dir");

  if ($argc!=2)
  {
      $JTN_newsdir=false;
  }

// decide where we'll get page title
// and content.

  if ($argv[0]=="")
  {
       $JTN_page=mgd_get_page($midgard->page);
       $JTN_pagetitle=$page->title;
       $JTN_is_default_page=true;
       $JTN_notfound=false;
  }
  elseif ($JTN_newsdir)
  {
      $JTN_topic=$argv[0];
      $JTN_article=$argv[1];
      if ($topic=mgd_get_topic_by_name(0,$JTN_topic))
        {
            if ($article=mgd_get_article_by_name($topic->id,$JTN_article))
            {
                $JTN_pagetitle=$article->title;
                $JTN_is_article=true;
                $JTN_notfound=false;
                $JTN_target=$article;
            }
        }
  }

  if ($notfound)
    {
        if (substr($SCRIPT_NAME,0,1)!="/")
        {
            $JTN_snippetname="$SNIPPETDIR/$SCRIPT_NAME"; 
        }
        else
        {
            $JTN_snippetname="/$SNIPPETDIR$SCRIPT_NAME";
        }
  }
  $temp1=strrchr($snippetname,"/");
  $temp2=substr($tempstring,1,strlen($temp1)-1);
  $temp3=substr($snippetname,0, strlen($snippetname)-strlen($temp2)-1);
  $temp4=mgd_get_snippetdir_by_path($temp3);
  $temp5=mgd_get_snippet_by_name($$temp4->id,$temp2);
  if ($temp5)
  {
      $JTN_pagetitle=$temp5->parameter("snippet","title");
      $JTN_is_snippet=true;
      $JTN_notfound=false;
      $JTN_target=$SCRIPT_NAME;
  }
}
else
{
    $JTN_notfound=false;
}

//echo $JTN_notfound;
if ($JTN_notfound)
{
    header("Status: HTTP/1.0 404 Not Found");
    echo "blah";
    exit;
}
?>
-- 
Steve Sobol, CTO  JustThe.net LLC, Mentor On The Lake, OH
http://JustTheNetLLC.com/  888.480.4NET (4638)

A practicing member of the Geek Orthodox religion!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to