Hi,


Here is a piece of code I wrote for an intranet, I provide it "as is" to
feed the debate...
You can put it in the code-init element of an ACTIVE page, and you'll need
the functions mgd_get_xxxx_by_name you can find at this url
(http://www.midgard-project.org/article/1420.html), or just wait for the
1.2.6 release of midgard.

This snippet initialize two global PHP objects, $ktopic and $karticle so you
can have them anywhere in your page/style code.

It works the following way:
on an active page, say /oldnews/, I want to get the topic and article
described by the url.
So if the url is /oldnews/midgard/doc/functions/mgd_get_topic.html
$ktopic will contain the topic called 'functions' under the topic tree
'/archives/midgard/doc'
$karticle will contain the article called 'mgd_get_topic' under the topic
'functions'.

Note: $karticle is not set if the url doesn't end with .html.

<?
$root_topic="archives";
if(ereg("^(.*)/(.*)|(.*\.html)$",$midgard->uri,$p))
{
  $kpath=$p[1]."/";
}
$topic=mgd_get_topic_by_name(0,$root_topic);
$max=(substr($midgard->uri,-5)==".html")?$argc-1:$argc;

for($i=0;$i<$max;$i++)
{
  $topic=mgd_get_topic_by_name($topic->id,$argv[$i]);
}
$ktopic=$topic;
if(isset($karticle))
  unset($karticle);
if(!empty($p[2]))
{
  $karticle=mgd_get_article_by_name($ktopic->id,$argv[$argc-1]);
}
?>


bye,
[EMAIL PROTECTED]


--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org

To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]

Reply via email to