Ask the community

This is a community support forum where you can ask
questions and interact with other PremiumPress Customers.

DP limit listing length

  • Carlo
    Carlo
    Newbie 8 points
    July 6, 2013 at 9:23 am

    Hi, is it possible to limit the length of a listing by setting max character count?

  • James
    James
    Newbie 42 points
    July 7, 2013 at 12:44 pm

    Hi Carlo,

    There are ways to do that. Here is an example of code to limit the short description field:

    [code title=””]<?php
    /* ================= Added By DeLime . Set length of Short Description Field*/
    if($dfs[‘excerpt’] != “1”){ ?>
    var short = document.getElementById(“form_short”);
    if(short.value.length > 300){
    alert(‘There are too many characters in the Short Description field. You currently have ‘ + short.value.length + ‘ and the limit is 300.’);
    short.style.border = ‘thin solid red’;
    short.focus();
    return false;
    }
    <?php }
    /* ================= End Added By DeLime . Set length of Short Description Field*/
    ?>[/code]

    It would go at around line 1152 in _tpl_add.php in the child theme.

    Jim

    • This reply was modified 6 years, 2 months ago by James James.
  • patrick
    patrick
    Newbie 37 points
    July 7, 2013 at 1:21 pm

    thanks for share

  • Mark Fail
    Mark Fail
    Super Guru 12,821 points
    July 7, 2013 at 2:43 pm

    Thanks for sharing Jim

  • Michael
    Michael
    Senior Member 141 points
    July 8, 2013 at 5:54 pm

    The above code gives an error:

    Parse error: syntax error, unexpected ‘<‘ in /home/gorod/public_html/wp-content/themes/directorypress/tpl-add.php on line 1153

  • Michal
    Michal
    Senior Member 118 points
    July 8, 2013 at 7:21 pm

    you are probably missing or more likely have to many “<” signs
    make sure line looks like this one

    </div> <!– end itembox –>

  • James
    James
    Newbie 42 points
    July 8, 2013 at 8:42 pm

    Michael,

    Pleae be sure the code is pasting in correctly and that all characters are there.

    And I notice that you are placing it into tpl-add.php … a core theme file … and not _tpl_add.php in your child theme. That will alter where the code is placed.

    And if it still gives you trouble, please show us where you are pasting it.

    Jim

  • Mark
    Mark
    Newbie 84 points
  • Mark Fail
    Mark Fail
    Super Guru 12,821 points
    July 17, 2013 at 2:32 am

    thanks Mark, i see you’ve been busy :)

  • Mark
    Mark
    Newbie 84 points
    July 17, 2013 at 12:37 pm

    Not busy. Just shirking my responsibilities!! 😳


  • Pascal
    Newbie 2 points
    July 31, 2013 at 6:59 am

    Hi all,
    What should i put if I want to define a minimum of character. And in diferent plan.

    Thanks

  • Mark Fail
    Mark Fail
    Super Guru 12,821 points
    July 31, 2013 at 9:32 am
    Not busy. Just shirking my responsibilities!!

    :)

Viewing 12 posts - 1 through 12 (of 12 total)