Skip Navigation

[Resolved] how does that more TAG in the "Fields and Text" block function?

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 1 year, 5 months ago.

Assisted by: Minesh.

Author
Posts
#2630915
does_more_exíst.jpg

Tell us what you are trying to do?

how does that more TAG in the "Fields and Text" block function?
see screenshot.

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

extern3
Let_me_in_2023ll us what you are trying to do?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2631149

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and what exactly you want to display.

Do you mean that you want to display Read More link for the WYSIWYG field content or your post content? For what post type or can you please share link of your post and share few screenshot what exactly you looking for and I will be able to guide you in the right direction.

#2631333
more_2.jpg

hi

hereunder you can see the frontend screenshot of the edit screen you recieved in preceding post.

I was awaiting that the insert of "more" would divide the text at this point, insert a "more-button" at the frontend and hide the remaining of the text until klicked at the "more button".

the only effect I can see is the introduction of a dashed line with "more" in the middle at the edit of the data (at the server) but on the frontend I do not see any effect!

I hope I explained well

best

Ed.

#2632025

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok there is no way to display read more using the WYSIWYG custom field. I would like to know when user click on "read more" link - do you want to display the hidden text or you want the user to redirect user to single post where whole single post is displayed?

#2632035

hi
I see you#re working on it.

so I do want to show 2 or 3 lines and have a more button to show if there is interest of it .
the reason is that a long text breaks the smoothness/design of the page

#2632037

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes but the "Read More" button when clicked by the user it will redirect user to that related single post page - is that Ok?

#2632059

No, simply show the text which was not shown.

That disarranges the design, but in that case it was the user who wanted it (and he knows that there is more stuff on the bottom of the shown page).

#2632083

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now:

I've added the following shortcode to your view's content template's "Fields and Text" block which is added within the conditional block:
=> hidden link

===============
[show_wysiwyg_with_readmore field="expo_short" chars="55" ellipsestext="...." moretext="more" lesstext="less"]

And I've added the following code to the "Custom Code" section offered by Toolset:
=> hidden link

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 = strip_tags( types_render_field($field, array('output' => 'raw')) );
 
    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; ?>+ '&nbsp;</span><span class="morecontent<?php echo $field; ?>"><span style="display: none;">' + h<?php echo $field; ?> + '</span>&nbsp;&nbsp;<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 above code is inspired from the following related ticket:
- https://toolset.com/forums/topic/implement-read-more-in-wysiwyg-fields-on-front-end-template/#post-2388905

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
- https://toolset.com/contractors/

#2632207

thanks

was perfect help!!!

best

Ed.