Skip Navigation

[Résolu] How to code a div in Types

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 réponses, has 2 voix.

Last updated by Dido Il y a 7 années et 8 mois.

Assigned support staff: Srdjan.

Auteur
Publications
#190053

A little complicated.
I have code a button in types. This was working well in version 1.3.1, but after updating something changed. I used output code from types in css, but in the latest version of Types, the output is cleaned up as I discover. Very nice of course, but not for my button.

I use the following code in functions.php:

function blauwe_knop ( ) {

$tekst = (types_render_field("tekst-knop", array()));
echo (types_render_field("link-knop", array("class"=>"button","title"=>"$tekst")));

$tekst = (types_render_field("tekst-knop", array()));
echo (types_render_field("mail-knop", array("class"=>"button","title"=>"$tekst")));
}

And this in content-page.php:

<?php if (types_render_field("positie", array()) == 'onder') blauwe_knop(); ?>

I made custom fields for the position of the button, text and link (or email).
You can choose on every page if you want a button or not.

see example: hidden link
code:

<div id="wpcf-field-link-knop" class="wpcf-field-url wpcf-field-link-knop">
<span class="wpcf-field-value wpcf-field-url-value wpcf-field-link-knop-value"><a href="hidden link" title="Contact with<br />Bierens" class="button">Contact with<br />Bierens</a></span>
</div>

After updating types I see this (cleaned html) on a clone site: hidden link
code:
<a href="hidden link" title="Contact with<br />Bierens" class="button">Contact with<br />Bierens</a>

As you see: All div id's, classes etc disapeard. I did not change anything myself!

My css based on the div id:
#wpcf-field-link-knop, #wpcf-field-mail-knop
{background:url(images/bierens-button.png) no-repeat;
width:95px
;height:40px;
margin-top:10px;
padding:3px 1px;
text-align:center;
line-height:13px}

So for showing the button I need this html output:
<div id="wpcf-field-link-knop"><a href="hidden link" title="Contact with<br />Bierens" class="button">Contact with<br />Bierens</a></div>

Where can I add this div code:
<div id="wpcf-field-link-knop">

Can anyone help me?

#190133

Dear Dido,
if you want to use same HTML output as in 1.3.1 version, you can add 'output' parameter.
Like:

echo types_render_field( "link-knop", array("class"=>"button","title"=>"$tekst", 'output' => 'html') );

Please tell me if this solves your issue.

#190147

Thank you very much! This is the solution.