rfe #12127: AssetProperty macro

This commit is contained in:
Paul Driver 2011-05-11 09:30:36 -05:00
parent 34eda690ee
commit 6a01296019
5 changed files with 82 additions and 0 deletions

View 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;