Add template field to StoryTopic. The same template will be shared between both modes.

Add top story variables, and tests.
This commit is contained in:
Colin Kuskie 2009-03-19 16:43:21 +00:00
parent 4b859e5ada
commit ea31d52ac0
5 changed files with 71 additions and 18 deletions

View file

@ -53,6 +53,15 @@ sub definition {
hoverHelp => $i18n->get('stories short help'),
defaultValue => 5,
},
templateId => {
tab => 'display',
fieldType => 'template',
label => $i18n->get('template'),
hoverHelp => $i18n->get('template help'),
filter => 'fixId',
namespace => 'Story',
defaultValue => 'liNZSK4xWGyALU6nu_criw',
},
storyTemplateId => {
tab => 'display',
fieldType => 'template',
@ -146,14 +155,24 @@ sub viewTemplateVariables {
STORY: foreach my $storyId (@{ $storyIds }) {
my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate});
next STORY unless $story;
my $creationDate = $story->get('creationDate');
push @{$var->{story_loop}}, {
url => $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}),
title => $story->getTitle,
creationDate => $creationDate,
creationDate => $story->get('creationDate'),
}
}
if ($self->{_standAlone}) {
my $topStoryData = $storyIds->[0];
shift @{ $var->{story_loop} };
##Note, this could have saved from the loop above, but this looks more clean and encapsulated to me.
my $topStory = WebGUI::Asset->new($session, $topStoryData->{assetId}, $topStoryData->{className}, $topStoryData->{revisionDate});
$var->{topStoryTitle} = $topStory->getTitle;
$var->{topStoryUrl} = $session->url->append($self->getUrl, 'func=viewStory;assetId='.$topStoryData->{assetId}),
$var->{topStoryCreationDate} = $topStory->get('creationDate');
##TODO: Photo variables
}
return $var;
}

View file

@ -19,13 +19,16 @@ our $HELP = {
],
fields => [],
variables => [
{ 'name' => 'story_loop',
'variables' => [
{ 'name' => 'url' },
{ 'name' => 'title' },
{ 'name' => 'creationDate' },
{ name => 'story_loop',
variables => [
{ name => 'url' },
{ name => 'title' },
{ name => 'creationDate' },
],
},
{ name => 'topStoryTitle' },
{ name => 'topStoryUrl' },
{ name => 'topStoryCreationDate' },
],
related => []
},

View file

@ -81,6 +81,24 @@ our $I18N = {
lastUpdated => 0,
},
'topStoryUrl' => {
message => q|The URL to view the top story.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'topStoryTitle' => {
message => q|The title of the top story.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'topStoryCreationDate' => {
message => q|The epoch date when the top story was created, or submitted, to its Story Archive.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'view template' => {
message => q|View Story Topic Template|,
context => q|Template variable.|,