
phillip at communitybandwidth
Jul 27, 2008, 3:01 PM
Post #4 of 5
(222 views)
Permalink
|
On 27-Jul-08, at 5:29 PM, Greg Heo wrote: >> Have to admit, I've never explored codeselects before. And I'm not >> finding any documentation or examples to work from. Any quick >> pointers? > > The basic idea is to build a hash where the hash key will become the > "value" part of the <option> element, and the hash value will be > what's displayed. So { '1024' => 'My Story' } will be HTMLized as > <option value="1024">My Story</option>. > > You'd probably need to do a story list and loop through to build the > hash: > > my %bios_hash; > my @bios_list = Bric::Biz::Asset::Business::Story- > >list({element_key_name => 'bio_page'}); > > foreach (@bios_list) { > $bios_hash{$_->get_id} = $_->get_title; > } > > return \%bios_hash; > > Assuming "bio_page" is the key name of the story element type; > publish_status, order, etc. should be added to the Story->list() as > required too. Bingo! :-) Cookies for Greg. On 27-Jul-08, at 5:33 PM, Scott Lanning wrote: > I'm not sure what you mean by returning the list > to the contributor screen. Code Select is a data field in a story, > just like Select lists but where the items are generated by code. Actually, the contributor type screen allows the addition of custom fields too, and one of the options is codeselect. In the scenario above, I'm providing a list of possible contributor bios (which are actual stories) on the Contributor -> New or Contributor -> Edit screen. In those stories, I'm storing a bunch of information, including contributor photos, etc. Working nicely now. Thanks! :-) Still working on this though: 3) If I use the roles option when looking up contributor data, how does one get the value on role-specific custom fields, e.g.: % my @contribs = $story->get_contributors; % foreach my $contrib (@contribs) { % my @roles = $contrib->get_roles; % foreach my $role (@roles) { % if ($role eq 'blogger') { % my $name = $contrib->get_name('%f %l'); % my $bio = $contrib->get_data('Bio'); % my $bio_id = $contrib->get_data('blog_bio_id_temp'); % my $contrib_id = $contrib->get_id; <% $role %> <% $bio %> <% $bio_id %> <% $name %> <% $contrib_id %> % } % } % } ... does not return the value for the custom fields for the "blogger" role; instead, it returns the values from the "default" role (with the exception of the $role, which is correctly returned as "blogger"). Any thoughts appreciated. -- Phillip Smith, Simplifier of Technology Community Bandwidth http://www.communitybandwidth.ca
|