[- $r = shift ; $config = $r -> {config} ; $dberr = '' ; eval { require DBIx::Recordset ; } ; $dberr = "DBI and DBIx::Recordset must be installed: $@" if ($@) ; if (!$dberr) { eval { *set = DBIx::Recordset -> Search ({'!DataSource' => $config -> {dbdsn}, '!Username' => $config -> {dbuser}, '!Password' => $config -> {dbpassword}, '!DBIAttr' => { RaiseError => 1, PrintError => 1, LongReadLen => 32765, LongTruncOk => 0, }, '!Table' => 'item, itemtext', '!TabRelation' => 'item_id = item.id', '!Order' => 'creationtime desc', 'language_id' => $r -> param -> language, 'category_id' => 1, 'state' => 1, '$max' => 8}) ; } ; $dberr = "Error accessing $config->{dbdsn}: " . DBIx::Recordset -> LastError . $@ if (DBIx::Recordset -> LastError || $@) ; } -]
 
[$if !$dberr $] [$while ($rec = $set -> Next)$]
  [- $date = $rec -> {modtime} ; $date =~ /^(\d+)-(\d+)-(\d+)/ ; $date = $r -> param -> language eq 'de'?"$3.$2.$1":"$2/$3/$1" ; -] [+ $date +]
[- $txt = $rec -> {description} ; $txt =~ s#<#<#g ; $txt =~ s#>#>#g ; $txt =~ s#B<(.*?)>#$1#g ; $txt =~ s#(http://[-a-zA-Z./0-9]+)#$1#g if (!($txt =~ s#L<\"(.*?)\"\|(.*?)>#$1#g)) ; -] [+ do { local $escmode = 0 ; $txt } +]
[$endwhile $]
 [= more_news =]
 [= add_news =]
[$else$]
  News not available because database is not correctly set up
[+ $dberr +]
To get the database related parts working, install DBI and DBIx::Recordset, setup a database for Embperl, create tables by running eg/webutil/setupdb.pl (make sure to edit the DSN inside the script first) and enter the correct DSN in eg/web/config.pl.
[$endif$]