Tell us what you are trying to do?
Recreate your solution of January 10, 2024 at 7:33 am '[Resolved] format of text using "more" ' you gave me on 'hidden link ' to the derived site 'hidden link '.
As I cannot find where and how to 'put' that script (I put it under documentation<- next point hereunder)
I cloned this site from the first one and I ask myself, as I do not remember, if I did it before or after you solved that formatting problem so please tell me also, case you know, if cloning the site with 'Duplicator Pro' clones that function also
Is there any documentation that you are following?
--->
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> ">' + moretext + ' </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();
}
}
<----
Is there a similar example that we can see?
What is the link to your site?
both sites enter with same user and password!!!
hidden link
hidden link
user: extern3
password: you_may_enter_20240617
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Well - the code you shared is added to "Custom Code" section as stated with the following ticket:
- https://toolset.com/forums/topic/format-of-text-using-more/#post-2677806
hi
I copied the "add_shortcode('show_wysiwyg_with_readmore', 'func_show_wysiwyg_with_readmore');" AND FOLLOWING LINES
from you answer on date January 10, 2024 at 7:33 am.
I am unable to use that function because I cannot figure out what (were) to do with that chunk of code!!!
pleas give me some clue where to put and how
Thanks
Ed.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
You can call the shortcode as given under:
[show_wysiwyg_with_readmore field="field-slug" chars="55" ellipsestext="...." moretext="more" lesstext="less"]
Where:
Please replace the "field-slug" with your original field slug.