Archived

This topic is now archived and is closed to further replies.

  • 0

Saving values from custom option "types"


Question

Posted · Report post

Howdy, I'm making a custom section and it needs a type-ahead box that searches for other custom post types to feature in it. The big question is how I save a custom option 'type' values (i.e., not one of the built-in "text", "checkbox", etc).

 
I've looked through the "pagelines-section-template" code, and watched the YouTube tutorials, but those all give examples of a "text" option type, not a custom one.  
 
I found the action inside `class.options.engine.php` for outputting the custom option type (below), so that's not a problem:
do_action( 'pagelines_options_' . $o['type'] , $oid, $o);
 
...but I'm falling short on finding where to save the option's values.
 
Thanks in advance!

Share this post


Link to post
Share on other sites

5 answers to this question

Posted · Report post

So after a long break I was able to get back to this and realized that the field just needed the proper name -- which comes from the $o (option element defined in the `section_optionator()` function.

 

Example defining option:

 

$options = array(
  'galleries' => array(
    'title' => 'Gallery',
    'type' => 'gallery_type_ahead',
    'inputlabel' => 'Gallery',
    'exp' => 'Start typing the name of the gallery you want to display.',
    'shortexp' => 'Pick your gallery you want to display.'
  ),
);

 

 

And now to output in the section admin

foreach ($o['val'] as $key => $gallery_id) {
  ?>
  <li>
    <input type="text" id="<?php echo esc_attr($o['input_id'].'-'.$key); ?>" name="<?php echo esc_attr($o['input_name']); ?>[]" class="gallery-typeahead" value="<?php echo intval($gallery_id); ?>" />
  </li>
  <?php
}

I believe I had been trying the $oid variable instead of the $o (which I know understand, stands for option).  Baby steps ;)

 

Now my question is how to validate the entered values, but I'll look around for that.

 

Thanks for everyones help!

Share this post


Link to post
Share on other sites

Posted · Report post

Hi there,

 

I'll speak to a member of the developer team to see if they can point you in the right direction and come back to you once I hear from them.

 

If you're looking into making a custom sections, you should look into signing up to our Junto/developer group http://developer.pagelines.com/apply/

Share this post


Link to post
Share on other sites

Posted · Report post

Why not use a dropdown of all available types?

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks Simon_P, but it's not to make available the listing of custom post types; The end result is to provide the user the ability to select multiple individual post type items.  

 

Example: 

There's a post type of videos

This section would allow the editors to type inside it for the name of a singular video; then click "+" to add another input to search for another video to populate this section with, and so on.

 

I haven't seen a section that allows for that type of functionality.

 

The issue I was having (and haven't been able to go back and test more yet) is the saving of the values of those text inputs that will contain the titles/ids of those videos.

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks James, I've done that as well and am waiting for their approval of my application.  If there's a way to hasten that process I'm game for that route too ;)

 

I look fwd to their reply!  Thanks!

Share this post


Link to post
Share on other sites