diff --git a/lib/WebGUI/Asset/Wobject/NewsletterCollection.pm b/lib/WebGUI/Asset/Wobject/NewsletterCollection.pm index d35d745..cce6d01 100644 --- a/lib/WebGUI/Asset/Wobject/NewsletterCollection.pm +++ b/lib/WebGUI/Asset/Wobject/NewsletterCollection.pm @@ -8,7 +8,7 @@ use Class::C3; use WebGUI::User::SpecialState; use base qw{ - WebGUI::AssetAspect::Mailable + WebGUI::AssetAspect::Mailable WebGUI::AssetAspect::Subscriber WebGUI::Asset::Wobject }; @@ -35,7 +35,7 @@ sub definition { defaultValue => 1, }, ); - + push @{ $definition }, { assetName => $i18n->get('assetName'), icon => 'newsletter_collection.gif', @@ -52,12 +52,16 @@ sub definition { sub getIssues { my $self = shift; - my $issues = $self->getLineage( [ 'children' ], { - returnObjects => 1, - orderByClause => 'lineage desc', - } ); - - return $issues; + # Caching of instanciated assets is not for speed, but is requied since prepareView is called on them, and we + # need them again in that state in getViewVars. + unless ( $self->{ _issues } ) { + $self->{ _issues } = $self->getLineage( [ 'children' ], { + returnObjects => 1, + orderByClause => 'lineage desc', + } ); + } + + return $self->{ _issues }; } #---------------------------------------------------------------------------- @@ -88,7 +92,8 @@ sub getAssetContent { my $self = shift; my $asset = shift; - $asset->prepareView; + # Do not call prepareView on $asset here but rather do this in our own prepareView to prevent head tags being + # written to body. my $content = $asset->view; return $content; @@ -106,6 +111,11 @@ sub prepareView { $self->{ _viewTemplate } = $template; + # Call prepareview on issues here, to prevent head tags ending up in the body. + foreach my $issue ( @{ $self->getIssues } ) { + $issue->prepareView; + } + return; } @@ -126,7 +136,7 @@ sub getViewVars { foreach my $issue ( @{ $issues } ) { my $issueVar = $issue->get; $issueVar->{ url } = $issue->getUrl; - + my $isRecent = ( !$displayIssueId && $recentCount < $maxRecent ) || ( $issue->getId eq $displayIssueId ) @@ -157,7 +167,7 @@ sub view { my $self = shift; my $form = $self->session->form; - my $var = $self->getViewVars( { + my $var = $self->getViewVars( { displayIssue => $form->guid('displayIssue'), } );