<%args> $preview => 0; <%init> use Storable qw(freeze thaw); use MIME::Base64 qw(decode_base64); my ($sth,$rowCount); if($preview){ $sth = $dbh->prepare("SELECT name,component,url,properties FROM module WHERE type = 'Main Module' AND enabled = 1 ORDER BY sort_order ASC"); $sth->execute(); $rowCount = $sth->rows; } else { $sth = $dbh->prepare("SELECT name,component,url,properties FROM module WHERE type = 'Main Module' AND published = 1 ORDER BY sort_order ASC"); $sth->execute(); $rowCount = $sth->rows; } <%method crumbs>\ <%args> $preview => 0 Home<% $preview ? ' (Preview)' : '' %>\
<%perl> my $rowNum = 1; my (%properties, @renderLast); while (my $row = $sth->fetchrow_hashref()) { my %params = (); # Each module's arguments are stored in $properties{params} # in the format 'param1=value1,param2=value2 ...' # Convert them to mason compatible for (param1=>value1,param2=>value2) if ($row->{properties}) { %properties = %{ thaw(decode_base64($row->{properties})) }; %params = map { split(/=/,$_) } split(/\s*,\s*/,$properties{params}); } $row->{params} = undef; if($properties{wide}) { $row->{params} = \%params; push(@renderLast, $row); } % if(!$properties{wide}) { % if($row->{name} =~ /Documents/) { <& com/document_section, name => "$row->{name}",%params, preview => $preview &> % } else { <& $row->{component}, %params, preview => $preview &> % } % $rowNum++; % } % }
<& com/rightcolumn, preview => $preview &>
% foreach my $row (@renderLast) {
% if($row->{params}) { <& $row->{component}, %{$row->{params}}, preview => $preview &> % } else { <& $row->{component}, preview => $preview &> % }
% }