Add template variables for determining if a story has photos, and how many it has.
Tests, help, i18n.
This commit is contained in:
parent
7b6ea1350f
commit
8b071cb892
4 changed files with 34 additions and 3 deletions
|
|
@ -763,8 +763,10 @@ sub viewTemplateVariables {
|
|||
$var->{updatedTimeEpoch} = $self->get('revisionDate');
|
||||
|
||||
$var->{crumb_loop} = $self->getCrumbTrail();
|
||||
my $photoData = $self->getPhotoData;
|
||||
$var->{photo_loop} = [];
|
||||
PHOTO: foreach my $photo (@{ $self->getPhotoData}) {
|
||||
my $photoCounter = 0;
|
||||
PHOTO: foreach my $photo (@{ $photoData }) {
|
||||
next PHOTO unless $photo->{storageId};
|
||||
my $storage = WebGUI::Storage->get($session, $photo->{storageId});
|
||||
my $file = $storage->getFiles->[0];
|
||||
|
|
@ -777,8 +779,11 @@ sub viewTemplateVariables {
|
|||
imageAlt => $photo->{alt},
|
||||
imageTitle => $photo->{title},
|
||||
imageLink => $photo->{url},
|
||||
}
|
||||
};
|
||||
++$photoCounter;
|
||||
}
|
||||
$var->{hasPhotos} = $photoCounter;
|
||||
$var->{singlePhoto} = $photoCounter == 1;
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ our $HELP = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{ name => 'hasPhotos', },
|
||||
{ name => 'singlePhoto', },
|
||||
{ name => 'photo_loop',
|
||||
'variables' => [
|
||||
{ name => 'imageUrl', },
|
||||
|
|
|
|||
|
|
@ -428,6 +428,24 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'hasPhotos' => {
|
||||
message => q|This template variable will be true if the Story has photos uploaded to it.|,
|
||||
context => q|Template variable|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'singlePhoto' => {
|
||||
message => q|This template variable will be true if the Story has just 1 photo uploaded to it.|,
|
||||
context => q|Template variable|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imageLink' => {
|
||||
message => q|A URL for the image to link to.|,
|
||||
context => q|Template variable|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue