change names of loops to be _loop vs Loop.
Added keyword loop variable. Change subtitle to a textarea. Add tests for Story template variables.
This commit is contained in:
parent
f37e98b982
commit
5bb4cbf299
3 changed files with 52 additions and 6 deletions
Binary file not shown.
|
|
@ -110,7 +110,7 @@ sub definition {
|
|||
defaultValue => '',
|
||||
},
|
||||
subtitle => {
|
||||
fieldType => 'text',
|
||||
fieldType => 'textarea',
|
||||
#label => $i18n->get('subtitle'),
|
||||
#hoverHelp => $i18n->get('subtitle help'),
|
||||
defaultValue => '',
|
||||
|
|
@ -223,7 +223,7 @@ sub getEditForm {
|
|||
name => 'title',
|
||||
value => $form->get('title') || $self->get('title'),
|
||||
} ),
|
||||
subTitleForm => WebGUI::Form::text($session, {
|
||||
subTitleForm => WebGUI::Form::textarea($session, {
|
||||
name => 'subtitle',
|
||||
value => $form->get('subtitle') || $self->get('subtitle')
|
||||
} ),
|
||||
|
|
@ -546,13 +546,25 @@ Template variables will be added onto this hash ref.
|
|||
sub viewTemplateVariables {
|
||||
my ($self) = @_;
|
||||
my $session = $self->session;
|
||||
my $var = $self->get;
|
||||
my $archive = $self->getArchive;
|
||||
my $var = $self->get;
|
||||
|
||||
if ($var->{highlights}) {
|
||||
my @highlights = split "\n", $var->{highlights};
|
||||
my @highlights = split "\n+", $var->{highlights};
|
||||
foreach my $highlight (@highlights) {
|
||||
push @{ $var->{highlightsLoop} }, { highlight => $highlight };
|
||||
push @{ $var->{highlights_loop} }, { highlight => $highlight };
|
||||
}
|
||||
}
|
||||
|
||||
my $key = WebGUI::Keyword->new($session);
|
||||
my $keywords = $key->getKeywordsForAsset( { asArrayRef => 1, asset => $self });
|
||||
$var->{keyword_loop} = [];
|
||||
foreach my $keyword (@{ $keywords }) {
|
||||
push @{ $var->{keyword_loop} }, {
|
||||
keyword => $keyword,
|
||||
url => $archive->getUrl("func=search;submit=1;keywords=".$session->url->escape($keyword)),
|
||||
};
|
||||
}
|
||||
##TODO: publish time, calculated from revisionDate
|
||||
return $var;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ use WebGUI::Storage;
|
|||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
my $tests = 1;
|
||||
plan tests => 13
|
||||
plan tests => 16
|
||||
+ $tests
|
||||
;
|
||||
|
||||
|
|
@ -123,6 +124,39 @@ cmp_deeply(
|
|||
'setPhotoData: wipes the stored data if nothing is passed'
|
||||
);
|
||||
|
||||
############################################################
|
||||
#
|
||||
# viewTemplateVariables
|
||||
#
|
||||
############################################################
|
||||
|
||||
$story->update({
|
||||
highlights => "one\ntwo\nthree",
|
||||
keywords => "foxtrot tango whiskey",
|
||||
});
|
||||
is($story->get('highlights'), "one\ntwo\nthree", 'highlights set correctly for template var check');
|
||||
my $viewVariables = $story->viewTemplateVariables;
|
||||
#diag Dumper $viewVariables;
|
||||
cmp_deeply(
|
||||
$viewVariables->{highlights_loop},
|
||||
[
|
||||
{ highlight => "one", },
|
||||
{ highlight => "two", },
|
||||
{ highlight => "three", },
|
||||
],
|
||||
'viewTemplateVariables: highlights_loop is okay'
|
||||
);
|
||||
|
||||
cmp_bag(
|
||||
$viewVariables->{keyword_loop},
|
||||
[
|
||||
{ keyword => "foxtrot", url => '/home/test-archive?func=search;submit=1;keywords=foxtrot', },
|
||||
{ keyword => "tango", url => '/home/test-archive?func=search;submit=1;keywords=tango', },
|
||||
{ keyword => "whiskey", url => '/home/test-archive?func=search;submit=1;keywords=whiskey', },
|
||||
],
|
||||
'viewTemplateVariables: keywords_loop is okay'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
END {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue