On Fri, Aug 18, 2000 at 12:21:44AM +0300, Alexander Bokovoy wrote:
> Hello Sergio,
> 
> > or, perhaps, an active page which execute static pages? 
>
> Probably  it's  better  to  use articles, especially with Midgard 1.4.
> Suppose that you have topic and articles in it named as $lang (article
> has 'name' and 'title' fields, so it is not a problem with them). Then
> you  can  create  active page which accepts ID for subtopic ('article'
> from  the  point  of view of visitor) and then looks for article named
> $lang in it.
> 
> <?php
> $article = mgd_get_article_by_name($id, $lang);
> ?>
> 
> And then display it.
> Pros: simplicity.
> Cons:  for each article you have to create sub-topic. There will be no
> articles   in   actual   topic  but  many  subtopics  which  represent
> 'articles'.
> 
> Another way is to use replies to articles as additional translations,
> but this way you need to fetch all replies until good one will be
> found because we have no function yet to get replies by name.
> 
> -- 
> Best regards,
>  Alexander                            mailto:[EMAIL PROTECTED]

I came with this solution:

in the page I only this:
<?
local_page();
?>

in a PHP_INIT element in the style:

function local_page() {
  global $lang;
  $mgd = mgd_get_midgard();
  $list = mgd_list_page_elements( $mgd->page );
  if(!$list) {
    echo "Can not get page content.<br>";
  } else {
    $ptbrID = -1;
    while( $list->fetch() ) {
      if (($list->name == "pt_BR") and ($ptbrID != -2)) {
        $ptbrID = $list->id;
      }   
      if ($list->name == $lang) {
        $ptbrID = -2;  
        $elem = mgd_get_page_element($list->id);
        ?> 
        &(elem.value:p); 
        <?
      }
    }
    if ($ptbrID >= 0) {
      $elem = mgd_get_page_element($ptbrID);
      ?> 
      &(elem.value:p); 
      <?
    }
  }
}

which retrieves the page *ELEMENT* with the same name of the current language,
$lang (en, pt_BR, es, etcetera). If the page element is not found, we retrieve
the default language, pt_BR in this case.

Note that with the :p modifier I can put even PHP code in the page elements.

With this setup I can solve the static content problem:

All pages will have only the <? local_page(); ?> content, and we put all the
real content in en, pt_BR, es, etcetera, page elements (even with PHP code.
UHU!!).



-- 

Sergio D. Bruder

[EMAIL PROTECTED], [EMAIL PROTECTED]
------------------------------------------
http://www.conectiva.com.br
http://sergio.bruder.net
http://pontobr.org

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