rfe #12127: AssetProperty macro
This commit is contained in:
parent
34eda690ee
commit
6a01296019
5 changed files with 82 additions and 0 deletions
43
lib/WebGUI/Macro/AssetProperty.pm
Normal file
43
lib/WebGUI/Macro/AssetProperty.pm
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package WebGUI::Macro::AssetProperty;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Macro::AssetProperty
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
^AssetProperty(sf76sd8f5s7f5s7618, title);
|
||||
^AssetProperty(root/import, assetId);
|
||||
|
||||
=head2 process( $session, $url_or_assetId, $propertyName )
|
||||
|
||||
Equivalent to calling $asset->get($propertyName)
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($session, $id, $name) = @_;
|
||||
my $asset = WebGUI::Asset->new($session, $id) if $session->id->valid($id);
|
||||
$asset ||= WebGUI::Asset->newByUrl($session, $id);
|
||||
|
||||
return $asset->get($name) if $asset;
|
||||
|
||||
$session->log->error("Invalid assetId or URL in AssetProperty: $id");
|
||||
return '';
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue