• Resolved danielecelsa

    (@danielecelsa)


    Hello,

    I noticed that if the title of a review is long enough AND does not contain any spacing between characters, the review itself and also all the others in that post are ‘broken’ both title and content.

    That’s because, I guess, without any spacing the title can’t go to a new line and continue to the right, and so all the other reviews also get this new ‘space’ available and so they also continue to the right.
    You can check here what I mean:
    https://imgur.com/a/ReYznBq

    Is there a way to limit the length of the title?
    I know how to limit the length of the review, but not the title

    Thanks in advance,
    Daniele

    • This topic was modified 3 years, 1 month ago by danielecelsa.
    • This topic was modified 3 years, 1 month ago by danielecelsa.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Thread Starter danielecelsa

    (@danielecelsa)

    Hello,

    thanks for your answer.

    Unfortunately the behavior is not what I was expecting:
    it seems that, when you write the title, there is not any limit and you can write as much as you want.
    BUT, if you try to submit the review, the review is not submitted and no advice or message about unsuccessful submitting is shown.

    Is there a way to better handle this situation of long title?
    Something that shows the limit when you write it or that tells you that the review is not submitted since the title is too long?

    As I showed you in first message, it seems a big bug since all the reviews become unformatted if the title of one is too long (and without spacing).

    Thanks a lot,
    Daniele

    Plugin Author Gemini Labs

    (@geminilabs)

    1. If the error message is not displaying, then your website is probably not loading the Site Reviews javascript file. If you are using a caching or optimisation plugin, you should check the settings. This is what it should look like: https://imgur.com/WIcfRAk

    2. This is not exactly a bug. If you are concerned about someone submitting a really long title with no spaces (this would likely only happen if someone is trying to spam you), then you can enable the “Require Approval” setting, enable one or more of the provided anti-spam options, and/or use the solution provided above.

    3. You can also use the following CSS solution (although it will not work with Internet Explorer):

    .glsr-review-title {
        overflow-wrap: anywhere;
    }
    Thread Starter danielecelsa

    (@danielecelsa)

    Hello,

    option 1 would be fine for me, and I guess the javascript file is loaded because in the other fields I receive the warning, as you can see here:
    https://imgur.com/a/mLXcBHb

    But for the title, I do not receive any red warning even if I write more than 80 character. In this case, the review seems submitted but actually it is not.
    Here you can see that I do not receive the red warning (I wrote more than 80 words):
    https://imgur.com/a/yIdLBdq

    Maybe I should add something to the code?

    Thanks in advance as always,
    Daniele

    Plugin Author Gemini Labs

    (@geminilabs)

    1. Please show a screenshot of how you are using the code snippet.

    2. Are you using any other snippets?

    3. Have you done any other customisations?

    Thread Starter danielecelsa

    (@danielecelsa)

    Hello,

    here a screenshot of my snippet, below there is another one to limit also the length of the review content:
    https://imgur.com/a/6mT2lTh

    Limit the length of review actually works, means that if I try to write more than 500 characters, I just can’t (I do not receive any red warning when try to submit, simply because I cannot write more than 500)

    I would prefer some red warning when try to submit like in your example:
    https://imgur.com/WIcfRAk
    but could be ok also if writing more than 80 characters would not be allowed (like for the review content)

    I don’t think I made some other particular customization.

    Maybe I should make the code for title similar to the one of the review? Like using the filter “review-form

    Thanks in advance

    Plugin Author Gemini Labs

    (@geminilabs)

    I’m not sure why the server-side validation is not working for you, although it sounds like a possible javascript or CSS conflict with your theme; without additional information about your website, I won’t be able to help you.

    However, if the client-side HTML5 validation is enough for you, then you can do this:

    /**
     * Client-side validation
     */
    add_filter('site-reviews/config/forms/review-form', function ($config) {
        if (array_key_exists('title', $config)) {
            $config['title']['maxlength'] = 80;
        }
        if (array_key_exists('content', $config)) {
            $config['content']['maxlength'] = 500;
        }
        return $config;
    });
    
    /**
     * Server-side validation
     */
    add_filter('site-reviews/validation/rules', function ($rules) {
        $rules['title'] = 'required|max:80';
        $rules['content'] = 'required|max:500';
        return $rules;
    });
    Thread Starter danielecelsa

    (@danielecelsa)

    Hello,

    thanks for your help.

    I tried this implementation and seems working:
    https://imgur.com/a/suNp5If

    I think it is the same of the one you proposed above, just less clean.. ??
    Can you confirm?

    Thanks for your help, after your confirmation we can close the case ??
    Daniele

    Plugin Author Gemini Labs

    (@geminilabs)

    Yours looks fine also.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limit title length’ is closed to new replies.