Mailing List Archive

[Bricolage-General] related media fields
Hey All,

I have a template for a chart, which is essentially an image with a bunch of
other formatting (caption fields, name, footnotes, etc). Now, the chart
image itself is related media, which width and height fields. From within
the chart template, I'd like to be able to access the width of the related
media, but can't seem to get it to work.

Reading the bric documentation, I'd assume it'd go something like this:
(inside the chart template)

my $width = $element->get_related_media->get_data('width');

but that doesn't work. Any help would be greatly appreciated.

Thanks!

Philip

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
Re: [Bricolage-General] related media fields [ In reply to ]
On Thu, 2 May 2002, Philip Fibiger wrote:

> Reading the bric documentation, I'd assume it'd go something like this:
> (inside the chart template)
>
> my $width = $element->get_related_media->get_data('width');
>
> but that doesn't work. Any help would be greatly appreciated.

Wild, untested guess:

my $width = $element->get_related_media->get_tile->get_data('width');

Although, in real production code you'll almost certainly want to be more
careful and check the return value of each of those method calls. If you
don't you'll get ugly errors when someone tries to creates a related media
element and doesn't pick a media object to relate.

-sam



_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
RE: [Bricolage-General] related media fields [ In reply to ]
I'm definitely going to do some checking of return values, i'm just
concerned at this point with what methods I need to call to actually access
that particular piece of data.

Correct me if i'm wrong, but get_related_media actually returns a $story
object and not an $element , and the $story object doesn't have the get_data
method. I don't understand why ->get_title would be any better, because it
doesn't return an $element either.

A second failed attempt was to use $media =
$element->get_container('related_media') and then $width =
$media->get_data('width')..

Does anyone know how I'd go about accessing that particular piece of data?

I apologize in advance if these are stupid newbie questions..I just started
working with bric a week or two ago. Again, this is in a chart template,
which has a related media that is the chart itself, which has a URI and then
height and width fields.

Phil

-----Original Message-----
From: Sam Tregar [mailto:sam@tregar.com]
Sent: Thursday, May 02, 2002 8:06 AM
To: Philip Fibiger
Cc: 'bricolage-general@lists.sourceforge.net'
Subject: Re: [Bricolage-General] related media fields

Wild, untested guess:

my $width = $element->get_related_media->get_tile->get_data('width');

Although, in real production code you'll almost certainly want to be more
careful and check the return value of each of those method calls. If you
don't you'll get ugly errors when someone tries to creates a related media
element and doesn't pick a media object to relate.

-sam


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
RE: [Bricolage-General] related media fields [ In reply to ]
On Thu, 2 May 2002, Philip Fibiger wrote:

> Correct me if i'm wrong, but get_related_media actually returns a $story
> object and not an $element

Ok, you're wrong! It returns a $media element
(Bric::Biz::Asset::Business::Media to be precise).

> and the $story object doesn't have the get_data
> method.

Correct.

> I don't understand why ->get_title would be any better, because it
> doesn't return an $element either.

Yes, it does, at least on stories. It returns a
Bric::Biz::Asset::Business::Parts::Tile::Container object which is more
commonly known as a container $element. Which doesn't mean my answer was
necessarily correct. I've never actually done what you're trying to do -
accessing the data elements on a related media object.

-sam



_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
RE: [Bricolage-General] related media fields [ In reply to ]
Ok..

$element->get_related_media would return an undefined value, so I figured I
needed to start from $element->get_container('related_media') .. After
looking through the documentation for
Bric::Biz::Asset::Business::Parts::Tile::Container, I ended up with:

my $related_media = $element->get_container('related_media');
my $relmedia = $related_media->get_related_media;
my $width = $relmedia->get_data('width');

which allowed me to access the data.

Hope this helps someone else in the future.

Phil

-----Original Message-----
From: Sam Tregar [mailto:sam@tregar.com]
Sent: Thursday, May 02, 2002 10:16 AM
To: Philip Fibiger
Cc: 'bricolage-general@lists.sourceforge.net'
Subject: RE: [Bricolage-General] related media fields


On Thu, 2 May 2002, Philip Fibiger wrote:

> Correct me if i'm wrong, but get_related_media actually returns a $story
> object and not an $element

Ok, you're wrong! It returns a $media element
(Bric::Biz::Asset::Business::Media to be precise).

> and the $story object doesn't have the get_data
> method.

Correct.

> I don't understand why ->get_title would be any better, because it
> doesn't return an $element either.

Yes, it does, at least on stories. It returns a
Bric::Biz::Asset::Business::Parts::Tile::Container object which is more
commonly known as a container $element. Which doesn't mean my answer was
necessarily correct. I've never actually done what you're trying to do -
accessing the data elements on a related media object.

-sam


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
Re: [Bricolage-General] related media fields [ In reply to ]
On 5/3/02 10:08 AM, "Philip Fibiger" <Philip.Fibiger@dfafunds.com> claimed:

> my $related_media = $element->get_container('related_media');
> my $relmedia = $related_media->get_related_media;
> my $width = $relmedia->get_data('width');

Ah yes, I think that this would be because the current element, which is in
$element, is not a related media element. It does, however, contain a
sub-element that's a related media element. That element happens to be
called "related_media", so you can get it from $element by calling
get_container(). However, the appropriate way to handle this would be to
create a separate template for the related_media sub-element, and in *that*
template, $element->get_related_media would give you your related media
object. Then you can call it from the element that contains the
related_media sub-element like this:

$burner->display_element($element->get_conainer('related_media'));

Or better yet, do this:

foreach my $e ($element->get_elements) {
if ($e->is_container) {
$burner->display_element($e);
} elsif ($e->has_name('paragraph');
$m->out('<p>');
$burner->display_element($e);
$m->out("<p>\n");
} # ... etc.
}

Whatever you can do to treat elements generically, without having to know
their names (particularly for container elements), the better.

HTH,

David

--
David Wheeler AIM: dwTheory
david@wheeler.net ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: Theory@jabber.org



_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general