This is the global (i've called it newsletters):
my ($output,$sth);
my $id = shift;
my $maildb = $DB->table('MailingIndex');
if ($id =~ /\d+/) {
$sth = $maildb->select({Mailing => $id});
} else {
$sth = $maildb->select({extra => 'Users'});
}
while (my $mail = $sth->fetchrow_hashref) {
if ($id =~ /\d+/) {
if ($mail->{'messageformat'} eq 'text'){$mail->{'message'} =~ s/\n/<br>/g;}
$output .= qq~<b>$mail->{'subject'}</b><br><br>$mail->{'message'}~;
} else {
$output.= qq~<li><a href="$CFG->{db_cgi_url}/page.cgi?p=newsletters&mail=$mail->{'Mailing'}">$mail->{'subject'}</a>~;
}
}
return $output;
}
Then you need to create a template newsletters.html. Use your normal page layout and in the body of the page add
<%if mail%>
<%newsletters($mail)%>
<%endif%>
To call the page with the list of newsletters use <%db_cgi_url%>/page.cgi?p=newsletters&mail=index
You'll probably need to edit the html in the global to get it looking how you want.
Code:
sub { my ($output,$sth);
my $id = shift;
my $maildb = $DB->table('MailingIndex');
if ($id =~ /\d+/) {
$sth = $maildb->select({Mailing => $id});
} else {
$sth = $maildb->select({extra => 'Users'});
}
while (my $mail = $sth->fetchrow_hashref) {
if ($id =~ /\d+/) {
if ($mail->{'messageformat'} eq 'text'){$mail->{'message'} =~ s/\n/<br>/g;}
$output .= qq~<b>$mail->{'subject'}</b><br><br>$mail->{'message'}~;
} else {
$output.= qq~<li><a href="$CFG->{db_cgi_url}/page.cgi?p=newsletters&mail=$mail->{'Mailing'}">$mail->{'subject'}</a>~;
}
}
return $output;
}
Then you need to create a template newsletters.html. Use your normal page layout and in the body of the page add
<%if mail%>
<%newsletters($mail)%>
<%endif%>
To call the page with the list of newsletters use <%db_cgi_url%>/page.cgi?p=newsletters&mail=index
You'll probably need to edit the html in the global to get it looking how you want.