Greetings!

On 15 Mar, Stephan Goeldi wrote:
>>In addition to P.Gillingwater's advice, I'd suggest studying the VMUC 
>>content handling scripts.
> In which directory can I found them?

Most of the pages in the VMUC site deal with
some level of content management, but the
/news page in the host will probably serve 
as the best example.

The /news page is an active one, meaning that
it is able to take arguments in format 
/article/arg1.html.

The page has some PHP code in the code-init
element that checks whether an article can
be found corresponding to the ID supplied
in the request URI. If such an article is
found, it is saved into the object 'article'
that includes all fields of the article 
database record as variables.

The contents of the code-init element could
be a bit more clear if written this way:

<?php
 # If we have only one argument
 if ($argc == 1) {

   # If the article referred to in the
   # argument can be found from topic tree 9    
   if (mgd_is_article_in_topic_tree(9, $argv[0])) {

     # Fetch the article
     $article = mgd_get_article($argv[0]);

     # If we got the article
     if ($article) {

       # Get info on its author as well
       $author = mgd_get_person($article->author);
     }
   }
 }

Now that we have handled the arguments and
fetching of a possible article in the code-init
element, it is time to worry about showing the
information in HTMl format. For this, we have
some PHP code in the page content 
(I'm simplifying the code here):

<?php

 # If code-init brought us an article
 if ($article) { ?>

   <h1>&(article.title);</h1>

   <p><b>&(article.abstract);</b></p>

   <!-- The article content in HTML format -->
   &(article.content:h);

 } ?>

Now, if there weren't any arguments for the
/news page, or the arguments supplied were
invalid, we'd rather give the user a list of
available articles, with link to the same
active page with their ID number as the argument.
Continuing the page content:

<?php 
 else { ?>

   <h1>News articles</h1>

   <?php

     # Fetch a list of available articles in topic 9
     $article = mgd_list_topic_articles(9);

     # If the topic contains articles
     if ($article) { ?>
     
       <ul>

       <?php
       # Do the following for each of the articles
       while ($article->fetch()) { ?>

         <li><a href="/news/&(article.id);.html"
                 >&(article.title);</a></li>

       <?php } ?>

       </ul>

       <p>Total articles: &(article.N);</p>

     <?php } 
 } ?>

Hopefully this helps. Handling content in Midgard
requires at least some understanding about PHP
coding (or a good amount of available copy-and-paste
code, but the first option is faster on the long
run), but it also gives a level of flexibility that
no cookie-cutter content management system can 
provide.

As an example, the article system in Midgard can
be used also for complex workflow systems besides
regular content management.

If you have any questions, or need help with getting
started, don't be afraid to contact this list. There
usually are people here who can help you out.

/Bergie

-- 
-- Henri Bergius -- +358 40 525 1334 -- [EMAIL PROTECTED] --
               http://www.iki.fi/Henri.Bergius


--
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