
adeola at creativeadea
Sep 5, 2011, 11:38 PM
Post #5 of 6
(631 views)
Permalink
|
|
Re: Is there a better way to get a single element?
[In reply to]
|
|
Ok I see what you're trying to do. Only problem is you need a way to order the elements and also I don't think you can get to the elements w/o first doing a get_elements('something') call. Then you can use get_value() on the returned elements to render them. See docs for advanced templates here: http://bricolagecms.org/docs/devel/api/Bric/AdvTemplates.html HTH, Adeola On 6 Sep 2011, at 02:49, Adam Wilson <adam [at] RFXTechnologies> wrote: > Adeola, > Thanks for the tip, but I was thinking there might be a way to get to a particular element without having to loop through the array. My example was a poor one, because I wouldn't really have done it that way. > > Here would be a better example. > >>> $burner->display_element( $homepageSections[2] ); >>> $burner->display_element( $homepageSections[1] ); >>> $burner->display_element( $homepageSections[0] ); >>> $burner->display_element( $homepageSections[3] ); > > Adam > > -----Original Message----- > From: users [at] lists [mailto:users [at] lists] On Behalf Of Adeola Awoyemi > Sent: Monday, September 05, 2011 9:14 PM > To: users [at] lists > Subject: Re: Is there a better way to get a single element? > > On 6 September 2011 02:09, Adeola Awoyemi <adeola [at] creativeadea> wrote: > >> >> >> On 5 September 2011 21:37, Adam Wilson <adam [at] rfxtechnologies> wrote: >> >>> I have a story with exactly 4 sections in it. >>> Each section gets called individually. >>> >>> I currently use this approach to get at each of the 4 sections. >>> my @homepageSections = $element->get_elements("section"); >>> $burner->display_element( $homepageSections[0] ); >>> $burner->display_element( $homepageSections[1] ); >>> $burner->display_element( $homepageSections[2] ); >>> $burner->display_element( $homepageSections[3] ); >>> >>> >>> Is there a better way to access each section? Perhaps something like: >>> $burner->display_element( $element->get_element("section")[0] ); >>> >> >> HI Adam, >> >> Try: >> >> my @homepageSections = $element->get_elements("section"); >> foreach (@homepageSections) { >> $burner->display_element( $_ ); >> } >> >> > Or for a shorthand version you can say: > > $burner->display_element( $_ ) foreach @homepageSections;
|