DP limit listing length

WordPress Business Themes Forums Version 7 Themes DirectoryPress DP limit listing length

DP limit listing length

July 6, 2013
Carlo Carlo
  • Carlo
    Carlo
    Newbie 8 points

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

    July 6, 2013 at 9:23 am
  • James
    James
    Newbie 42 points

    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 5 years, 11 months ago by James James.
    July 7, 2013 at 12:44 pm
  • patrick
    patrick
    Newbie 37 points

    thanks for share

    July 7, 2013 at 1:21 pm
  • Mark Fail
    Mark Fail
    Super Guru 12,812 points

    Thanks for sharing Jim

    July 7, 2013 at 2:43 pm
  • Michael
    Michael
    Senior Member 141 points

    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

    July 8, 2013 at 5:54 pm
  • Michal
    Michal
    Senior Member 118 points

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

    </div> <!– end itembox –>

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

    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

    July 8, 2013 at 8:42 pm
  • Mark
    Mark
    Newbie 84 points
  • Mark Fail
    Mark Fail
    Super Guru 12,812 points

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

    July 17, 2013 at 2:32 am
  • Mark
    Mark
    Newbie 84 points

    Not busy. Just shirking my responsibilities!! 😳

    July 17, 2013 at 12:37 pm

  • Pascal
    Newbie 2 points

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

    Thanks

    July 31, 2013 at 6:59 am
  • Mark Fail
    Mark Fail
    Super Guru 12,812 points
    Not busy. Just shirking my responsibilities!!

    :)

    July 31, 2013 at 9:32 am
Viewing 12 posts - 1 through 12 (of 12 total)

Didn't find what you were after?

Chat with us now

or contact our support team