0

I was hoping to output the available options in my P&T Fieldpack Dropdown field with a template (into a dropdown used to filter results) but am having no luck.

I've seen some folks referencing a tag pair like {options:papers_type} but I'm getting nowhere. Is anyone else familiar with how to do this?

Feels like I must be missing something. Merci!

2

Low Options can output native and P&T dropdown options in your templates.

| improve this answer | |
  • Nice little (secret) plugin Low :) I've never seen this on your site for some reason though, good to know about it! – Blatant May 26 '15 at 11:03
  • While I wish this functionality was build into P&T fieldpack, this solves the problem. Gracias. – philzelnar May 27 '15 at 13:10
0

it doesn't look like your missing anything, I've checke the docs but they are a little spartan to say the least...

If yuo wanted to simply display the field within a {exp:channel:form} SAEF it seems you can use the {field:var_name} syntax, you should also be abel to use the variable tag pair syntax within the Cahnnel Form. However it sounds like you just want to use the options in a custom dropdown as you mention 'a filter'

You still have some options, but if you're dead set on extracting the optoins from the P&T Dropdown on a Channel Field (rather than recreating them in a snippet/global variable or summin) you could roll your own PHP Sql query to get them or attempt to use the EE Template API to get the options/render the field again using PHP.

Let me know if you want a concise example, I'll have to knock one together. However in the meantime these docs might get you on the right path...

Edit: Been a while since I dipped into the Channel Fields API, so I tried an example. The following snippet will get you the options (as a key => value array) for a P&T Dropdown, provided you know the Channel (1) and Field ID (3) :

<?php

  //instansiate the channel entries API
  ee()->load->library('api');
  ee()->api->instantiate('channel_fields');

  //assuming Channle has ID of 1
  $channelSettings = ee()->api_channel_fields->setup_entry_settings('1', array());

  //assuming dropdown is field ID of 3
  $fieldOptions = empty($channelSettings['field_id_3']['options']) : array() ? $channelSettings['field_id_3']['options'];
?>
| improve this answer | |
  • Accepting this as the answer, since at the end of the day the main bit is that it's not an option built into the P&T dropdown. While the custom query is a good idea, Low Options did the trick for me. – philzelnar May 27 '15 at 13:14
  • Hi alsophil, Thanks but I actually think that Low's answer is deserving of the tick. It's less 'hacky' and is the solution you actually used! – Blatant May 28 '15 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.