Set the minimum number of characters for the tags.

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008, 01:01 PM
clems365's Avatar
Casual Pligger
Pligg Version: 9.8.2
Pligg Template: CMS Theme
 
Join Date: May 2007
Location: santiago chile
Posts: 56
Hi all

Like the title story or story description, I would like to make the same for the tags clouds (min characters 4).

I saw in the database and make a look :

PHP Code:
(71'Submit''minTitleLength''10''10''number''Minimum Title Length''Set the minimum number of characters for the story title.''define'NULL), 
It could be something like that:

PHP Code:
(71'tags''minTagLength''4''4''number''Minimum Tags Length''Set the minimum number of characters for the tags.''define'NULL), 
I believe it will be more or less the same, but... I don't now how to make it

Somebody could help me

Thanks a lot

Best regards

Clément
Reply With Quote
  #2 (permalink)  
Old 05-27-2008, 03:12 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
There is no feature to set the number of characters for the tag word in the admin pannel. You might try this while users submit a story.

Open /yourtemplate/submit_step_2.tpl and insert the following code within the {literal} {/literal}

Code:
<SCRIPT language="JavaScript">
<!--
function checkTags() {
 var tags=window.document.thisform.tags.value
  if (tags=="") {
   alert('Please enter at least one tag');
   window.document.thisform.tags.focus();
   exit;
  }
  if (tags.indexOf(",")== -1) {
   if (trim(tags).length < 4) {
    alert("The tag word must be at least 4 characters. Please correct it.");
   }
  }
  if (tags.indexOf(",")!= -1) {
   var tag_array=window.document.thisform.tags.value.split(",");
   var tags_num=0;
   while (tags_num < tag_array.length) {
    if (trim(tag_array[tags_num]).length < 4) {
       alert("The tag '" + tag_array[tags_num] + "' is less than 4 characters. Please correct it.");
      }
      tags_num+=1;
     }
  }
}
 
function trim(str) {
   return str.replace(/^\s+|\s+$/g,'');
}
//-->
</SCRIPT>
Go to this line where the input fields for the tags is and add the red part:
Code:
<input type="text" id="tags" name="tags" value="{$tags_words}" size="60" maxlength="40" onClick="checkTags();"/>
Now, as soon as the Tags field looses focus. the function checks the following:
  1. If the Tags field is empty, it alerts the user, gives the focus back to this field and exit the function.
  2. If only one tag was entered (no comas), it trims the value and checks its length. If the length is less than 4, it sends an alert.
  3. If more than one tag were entered, it splits and iterates through the tags and checks the trimmed length for each. If the length is less than 4, it sends an alert.
I hope this helps

Last edited by redwine; 05-27-2008 at 03:31 PM.
Reply With Quote
  #3 (permalink)  
Old 05-27-2008, 04:51 PM
clems365's Avatar
Casual Pligger
Pligg Version: 9.8.2
Pligg Template: CMS Theme
 
Join Date: May 2007
Location: santiago chile
Posts: 56
many thanks I will try
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tags should have 4 letters minimum Eddy Questions and Comments 0 05-20-2009 09:30 AM
minimum characters on submit page davebowker Questions and Comments 3 07-20-2008 09:30 PM
Tags not cloud in Pligg v9.9 bhatiacane Questions and Comments 4 05-03-2008 03:16 AM
set a minimum limit on tags? abraxas Questions and Comments 0 03-05-2008 07:13 PM
Pligg 9.1 problem with tags and international characters jackdaw Questions and Comments 0 03-02-2007 08:21 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development