Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2007, 07:13 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Shorten URLs

I have a problem with long URLs in the commments and story texts (http://forums.pligg.com/general-help...ry-text.html): They end in the middle of the sidebar.

Is it possible to shorten their display like it is here in preview mode: some 20 characters and three dots ?


P.S.: If I would know how to code the story-id (Individual comment link) some of my problems would disappear. :-)
Reply With Quote
  #2 (permalink)  
Old 07-16-2007, 10:08 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Anyone interested?
Reply With Quote
  #3 (permalink)  
Old 07-16-2007, 11:29 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Could this code be helpful apart from the missing dots at the end?

<?php

$text = preg_replace('@http://((\S{1,20})\S+)@','<a href="http://\\1" target="_blank">\\2</a>',$text);

?>
Reply With Quote
  #4 (permalink)  
Old 07-16-2007, 03:49 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
I´ve found a wordpress plugin called shrinkylink (void *). Maybe it can be used with little adaption.
Reply With Quote
  #5 (permalink)  
Old 07-17-2007, 05:28 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Another solution would be wrapping. See on the browser side (FF): https://addons.mozilla.org/de/firefox/addon/2547
Reply With Quote
  #6 (permalink)  
Old 07-17-2007, 06:04 PM
kbeeveer46's Avatar
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,547
Thanks: 254
Thanked 649 Times in 513 Posts
Here is a function that will shorten text to a certain amount of characters

PHP Code:
function ShortenText($text) {
    
$chars 20;

  
$text $text." ";
  
$text substr($text,0,$chars);
  
$text substr($text,0,strrpos($text,' '));
  
$text $text."...";

  return 
$text;
  }        
    
?> 
Sample usage:

Code:
$sampleText = 'This is some sample text. This is some sample text'

ShortenText(sampleText);
Output:
Code:
This is some sample ...
Basically you pass whatever you want into the ShortText function and it will only display 20 chars and three periods on the end.

BTW, I have lost my touch for PHP since I program in ASP.NET all day so it may not be perfect.
__________________
I accept donations for my time helping users like you on the forum and IRC.
Reply With Quote
  #7 (permalink)  
Old 07-18-2007, 01:30 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Thank you kbeeveer46,

but I have no clue where to call that function. In text_to_html (auto-recognition of hyperlinks in story text) ?
Reply With Quote
  #8 (permalink)  
Old 07-28-2007, 09:33 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Anyone interested?
Reply With Quote
  #9 (permalink)  
Old 09-02-2007, 09:35 PM
AshDigg's Avatar
Coder
 
Join Date: Dec 2005
Posts: 1,574
Thanks: 235
Thanked 345 Times in 206 Posts
This will truncate the story titles. Still working on something for the comments. Click on the 'text changed' links to see the changes that need to be made.
__________________
- Ash
Reply With Quote
  #10 (permalink)  
Old 09-04-2007, 04:47 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
Thank you, I guess you missed a '' at line 17 of sidebarstories.php.

I not sure wheter I got you right: I have a problem with long URLs in the description of a story and in comments, respectively. This has also consequences to the sidebar display of those URL links.

I´ve encountered another severe problem: Large comments lead to a size at comment management that pushes the check box for deletion under the sidebars, i.e. they´re without a function. Could you please fix that?

Another question: Is revision 1237 related to this problem (http://forums.pligg.com/bug-report/7...sidebar.html)?
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anyone got Friendly Urls (Url Method 2) working? revolver General Help 11 05-08-2008 12:32 AM
Suggestion: Friendlier urls for user page revolver General Help 0 07-06-2007 12:44 PM
Friendly URL's for categories works, but for stories not sixlaneve General Help 5 01-16-2007 12:20 AM
Problem with URLs linking to pages not found frhs00 Bug Report 7 12-29-2006 05:35 PM
Simplified Friendly Urls idea revolver Suggestions 0 11-07-2006 01:20 PM


Search Engine Friendly URLs by vBSEO 3.2.0