Call prepareView on child assets in the prepareView phase to prevent their head tags showing up in our body.
This commit is contained in:
parent
d325e7a301
commit
fffdb9d1a0
1 changed files with 21 additions and 11 deletions
|
|
@ -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'),
|
||||
} );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue