WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom Field Template] Issue with drop down html output (6 posts)

  1. solidnuts
    Member
    Posted 4 years ago #

    Hi, I'm trying to use the drop down feature so i can selct from 3 options with the value being html, here is what i'm using:

    [licence]
    type = select
    value = <a rel="nofollow" href="http://creativecommons.org/licenses/by/3.0/">Attribution (Creative Commons)</a>
    default =

    and this is the the result i get

    <a rel=\"nofollow\" href=\"http://www.gnu.org/copyleft/gpl.html\" target=\"_blank\">General Public License</a>

    so it seems like it adds forword slash's at every html quotation mark

    any idea how to fix this please?
    Thanks

  2. proximity2008
    Member
    Posted 4 years ago #

    Hi Solid,

    You'd have to use the code section in the CFT.

    [licence]
    type = select
    code = 0

    Then in the Code 0 area:

    $values = array();
    $values[] ='<a rel="nofollow" href="http://creativecommons.org/licenses/by/3.0/">Attribution (Creative Commons)</a>';
    $values[] ='<a rel="nofollow" href="http://creativecommons.org/licenses/by/3.0/">Second Option</a>';
    $values[] ='<a rel="nofollow" href="http://creativecommons.org/licenses/by/3.0/">Third Option</a>';

    This should do it.
    Have a nice day.

  3. solidnuts
    Member
    Posted 4 years ago #

    Thank you so much for your help.

  4. ddecort
    Member
    Posted 4 years ago #

    How would I set the default of a textfield to be an image with a link? Right now it escapes the quotes with slashes, so the default isn't working html.

    Here is my original example:

    [Marketing Area 1]
    type = textarea
    rows = 4
    cols = 40
    tinyMCE = true
    htmlEditor = true
    default = <img class="size-full wp-image-98 alignnone" style="border: 0pt none; margin: 0px;" title="marketing1" src="http://www.markettrendsignal.com/wordpress/wp-content/uploads/marketing1.jpg" alt="marketing1" width="741" height="204" />
    mediaButton = true

    That returned as the default in the page editor:

    <img class="\"size-full" style="\" title="\"marketing1\"" src="\" alt="\"marketing1\"" width="\"741\"" height="\"204\"" />

    which obviously won't work.

    I then tried putting that in the "php code", "#0" area:

    $value = <img class="size-full wp-image-98 alignnone" style="border: 0pt none; margin: 0px;" title="marketing1" src="http://www.markettrendsignal.com/wordpress/wp-content/uploads/marketing1.jpg" alt="marketing1" width="741" height="204" />

    and updated my template to this:

    [Marketing Area 1]
    type = textarea
    rows = 4
    cols = 40
    code = 0
    tinyMCE = true
    htmlEditor = true
    default = $value
    mediaButton = true

    But it just returns "$value" in the editor.

    I know i'm missing something here and am just guessing at this point. The example for the type = select doesn't seem to apply to setting the default for a text field.

    Any help is greatly appreciated.

  5. Hiroaki Miyashita
    Member
    Posted 4 years ago #

    Hi ddecort,
    Please update the plugin to the latest version 1.4.3. I fixed the quotation problems. You do not need to struggle with the php code any more. Just set the default attribute. Thanks.

  6. dehuszar
    Member
    Posted 4 years ago #

    I am having a similar problem. I am trying to create a select list from a variable which contains an array (specifically of images attached to the post, but when clicking on the dropdown I only see the variable in plain text. Any help would be appreciated.

    The custom field key looks like this:

    [color-splashes]
    code = 0
    hideKey = true
    label = Upload Color Splash
    multiple = true
    multipleButton = true
    type = select
    value = $attachments

    And the code 0 block looks like this:
    $attachments = array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'post_parent' => $post->ID);

    What am I doing wrong?

Topic Closed

This topic has been closed to new replies.

About this Topic