Add a template variable to tell if the Topic is viewed standalone by URL, or not.

This commit is contained in:
Colin Kuskie 2009-03-19 16:55:14 +00:00
parent ea31d52ac0
commit db839e2dc4
4 changed files with 11 additions and 1 deletions

View file

@ -172,6 +172,7 @@ sub viewTemplateVariables {
$var->{topStoryCreationDate} = $topStory->get('creationDate'); $var->{topStoryCreationDate} = $topStory->get('creationDate');
##TODO: Photo variables ##TODO: Photo variables
} }
$var->{standAlone} = $self->{_standAlone};
return $var; return $var;
} }

View file

@ -19,6 +19,7 @@ our $HELP = {
], ],
fields => [], fields => [],
variables => [ variables => [
{ name => 'standAlone' },
{ name => 'story_loop', { name => 'story_loop',
variables => [ variables => [
{ name => 'url' }, { name => 'url' },

View file

@ -99,6 +99,12 @@ our $I18N = {
lastUpdated => 0, lastUpdated => 0,
}, },
'standAlone' => {
message => q|This variable will be true if the Story Topic is being viewed directly, by its URL. Otherwise, if it is viewed as part of a Page Layout or other Container, it will be false.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'view template' => { 'view template' => {
message => q|View Story Topic Template|, message => q|View Story Topic Template|,
context => q|Template variable.|, context => q|Template variable.|,

View file

@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
my $tests = 8; my $tests = 10;
plan tests => 1 + $tests; plan tests => 1 + $tests;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -119,6 +119,7 @@ ok(
&& ! exists $templateVars->{topStoryCreationDate}, && ! exists $templateVars->{topStoryCreationDate},
'topStory variables not present unless in standalone mode' 'topStory variables not present unless in standalone mode'
); );
ok(! $templateVars->{standAlone}, 'viewTemplateVars: not in standalone mode');
$topic->{_standAlone} = 1; $topic->{_standAlone} = 1;
$templateVars = $topic->viewTemplateVariables(); $templateVars = $topic->viewTemplateVariables();
@ -161,6 +162,7 @@ is(
'viewTemplateVars in standalone mode, url' 'viewTemplateVars in standalone mode, url'
); );
is($templateVars->{topStoryCreationDate}, $now, 'viewTemplateVars in standalone mode, title'); is($templateVars->{topStoryCreationDate}, $now, 'viewTemplateVars in standalone mode, title');
ok($templateVars->{standAlone}, 'viewTemplateVars: in standalone mode');
$topic->update({ $topic->update({
storiesShort => 20, storiesShort => 20,