Tell us what you are trying to do?
I used a function I got from toolset support (maybe waquar) that empowers the extension of a text from a certain number of letters to the complete text.
you may see and try on : hidden link
I put 2x the same text. the 2d (without "more" button) is well formated the 1st (with button) not
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
hidden link
access removed
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
I see the shortcode added to the "Custom code" section and I've modified that as given under:
add_shortcode('show_wysiwyg_with_readmore', 'func_show_wysiwyg_with_readmore');
function func_show_wysiwyg_with_readmore($atts) {
$field = $atts['field'];
$chars = $atts['chars'];
$ellipsestext = $atts['ellipsestext'];
$moretext = $atts['moretext'];
$lesstext = $atts['lesstext'];
$field_content = types_render_field($field, array('output' => 'raw')) ;
$field_content = str_replace("<br/>", "\n", $field_content);
$field_content = strip_tags( $field_content );
$field_content = str_replace("\n", "<br/>", $field_content);
if(!empty($field_content)) {
$field = str_replace('-', '', $field);
ob_start();
echo '<div class="more'.$field.'">';
echo $field_content;
echo '</div>';
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var showChar<?php echo $field; ?> = <?php echo $chars; ?>;
var ellipsestext<?php echo $field; ?> = '<?php echo $ellipsestext; ?>';
var moretext<?php echo $field; ?> = '<?php echo $moretext; ?>';
var lesstext<?php echo $field; ?> = '<?php echo $lesstext; ?>';
$('.more<?php echo $field; ?>').each(function() {
var content<?php echo $field; ?> = $(this).html();
if(content<?php echo $field; ?>.length > showChar<?php echo $field; ?>) {
var c<?php echo $field; ?> = content<?php echo $field; ?>.substr(0, showChar<?php echo $field; ?>);
var h<?php echo $field; ?> = content<?php echo $field; ?>.substr(showChar<?php echo $field; ?>-1, content<?php echo $field; ?>.length - showChar<?php echo $field; ?>);
var html<?php echo $field; ?> = c<?php echo $field; ?> + '<span class="moreellipses<?php echo $field; ?>">' + ellipsestext<?php echo $field; ?>+ ' </span><span class="morecontent<?php echo $field; ?>"><span style="display: none;">' + h<?php echo $field; ?> + '</span> <a href="" class="morelink<?php echo $field; ?>">' + moretext<?php echo $field; ?> + '</a></span>';
$(this).html(html<?php echo $field; ?>);
}
});
$(".morelink<?php echo $field; ?>").click(function(){
if($(this).hasClass("<?php echo $lesstext; ?>")) {
$(this).removeClass("<?php echo $lesstext; ?>");
$(this).html(moretext<?php echo $field; ?>);
} else {
$(this).addClass("<?php echo $lesstext; ?>");
$(this).html(lesstext<?php echo $field; ?>);
}
$(this).parent().prev().toggle();
$(this).prev().toggle();
return false;
});
});
</script>
<?php
return ob_get_clean();
}
}
The lines I've adjusted are as given under:
$field_content = types_render_field($field, array('output' => 'raw')) ;
$field_content = str_replace("<br/>", "\n", $field_content);
$field_content = strip_tags( $field_content );
$field_content = str_replace("\n", "<br/>", $field_content);
Can you please confirm it works as expected now.
fine thanks
I'll compare to the former state to understand the changes.