List Info

Thread: Okay, stupid question about getting the data of a container elemenent




Okay, stupid question about getting the data of a container elemenent
user name
2007-10-02 15:16:13
I'm totally stuck in a bizarre way on this (seemingly
simple)  
template. Here's an outline of what I'm trying to get at:

cover.mc
  |-> related_story.mc
      |-> Story
	  |-> Author (container element)
		|-> Author (field / data) <- This is the data that
after!

I'm working on related_story.mc (cover.mc iterates over the
related  
stories to produce a list) and I want to print out the data
from the  
container element "author" in the the returned
story. I can get the  
container to print out via:

<%
$burner->display_element($rel_story->get_container(&qu
ot;author")) %>

... but that also returns the output from author.mc. All I
really  
want is the data from the author element. I can get what I
want like so:

foreach my $e ($rel_story->get_elements) {
   if ($e->has_name('author')) {
      my $author_data = $e->get_data('author');
      print "$author_data";
		}
	}

But that's *so* fugly. Is there a nicer way to do this?
(Please tell  
me it's just my brain that's failing me today!)

Phillip.

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth



Re: Okay, stupid question about getting the data of a container elemenent
user name
2007-10-02 15:45:38
On Oct 2, 2007, at 13:16, Phillip Smith wrote:

> foreach my $e ($rel_story->get_elements) {
>   if ($e->has_name('author')) {
>      my $author_data = $e->get_data('author');
>      print "$author_data";
> 		}
> 	}
>
> But that's *so* fugly. Is there a nicer way to do this?
(Please  
> tell me it's just my brain that's failing me today!)

Something like this, perhaps?

if (my $au = $rel_story->get_field('author')) {
     print $au->get_value;
}

Best.

David

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )