SourceTec Software

It is currently Thu Apr 24, 2014 4:13 am

All times are UTC + 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Aug 24, 2006 7:00 am 
Offline
Poster

Joined: Wed Mar 15, 2006 8:51 am
Posts: 54
I found that if I a dynamic menu title was wider than the allocated width of the menu the text would stretch the menu and not wrap.

Looking through this forum I found that this is the way the program works.

So I wrote this script in ASP/VBScript that works fine for me and I thought I'd share it.

Note: You can only set the maximum character length of the line before it breaks and not the pixel width, but it's better than nothing.

Anyhow, here's the code...

Place this function anywhere before the menu or in an include file.

Code:
<%
Function WrapLine(txt,lineLength)
dim l,t(),n,s
l=linelength
s=Split(txt)
n=0
ReDim t(n)
   For i = 0 To Ubound(s)
      If Len(t(n)&s(i))<l Then
         t(n)=t(n)&" "&s(i)
      Else
         t(n)=t(n)&"<br />"
         i=i-1
         n=n+1
         ReDim Preserve t(n)
      End If
   Next
   For i=0 To Ubound(t)
      Response.Write(t(i))
   Next
End Function
%>


Then you call the function in the text link (html) in the properties panel like this...

Code:
<%=WrapLine(rs("title"),25)%>


Change 25 to whatever maximum character width you need.


Hope this helps.
Nico


.


Last edited by niconedz on Tue Sep 19, 2006 11:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 11:24 pm 
Offline
Support Team
Support Team

Joined: Fri Jan 28, 2005 5:15 pm
Posts: 1866
Hi niconedz,

Thanks a lot for sharing your solution!

We appreciate it very much! :D


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 7:47 pm 
Offline
Member

Joined: Tue Sep 19, 2006 7:30 pm
Posts: 1
Here's the equivalent in PHP if anyone's interested:

Code:
function wrap_line($text,$line_length) {
  $split_text = explode(" ",$text);
  foreach($split_text as $key => $value) {
    if (strlen($line_concat.$value) < $line_length) {
      $concat .= " ".$value;
      $line_concat .= " ".$value;
    }
    else {
      $concat .= "<br />".$value;
      $line_concat = $value;
    }
  }
  return(trim($concat));
}


Top
 Profile  
 
 Post subject: Flexible & Simple Method
PostPosted: Wed Nov 08, 2006 12:32 pm 
Offline
Member
User avatar

Joined: Sat Oct 21, 2006 5:09 am
Posts: 8
Location: Turkey
Code:
function wrap_line($text,$line_length) {
return "<table><tr><td>$text</td></tr></table>";
}


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 1:39 am 
Offline
Support Team
Support Team

Joined: Fri Jan 28, 2005 5:15 pm
Posts: 1866
Hello everyone here,

Thanks for all the information you provided! :D


Top
 Profile  
 
PostPosted: Wed Jun 22, 2011 12:09 am 
Offline
Member

Joined: Wed Jun 22, 2011 12:06 am
Posts: 1
I'm trying to find code to achieve the same result using javascript.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 8 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group