Better Read More (in Link)

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2007, 11:10 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Hello guys,
this is pretty simple thing - each link has its own "read more" link which refer to its own page. Sometimes it is not neccessary - if link description(content) is not long, user see nothing new and "read more" link is in this case useless. User can be confused also.

See the picture below. I also highlighted the link with a small arrow-image:

As you can see the first link has not read more,on the contrary the second link has it.

Requirements
This is really easy and simple modification which can be implemented to almost every version 0.9 version of Pligg. Personally I have yget template but there is a big chance this could be appliable to all templates.

Steps to do
- Make Backup of edited files

1) Open link.php in your libs folder
2) find $smarty->assign('link_submitter', $this->username()); and before that add following code:
PHP Code:
        // if link content < 160 chars then no "MORE" link
        
if (strlen($this->content)>165){
        
$smarty->assign('long_content',true);          
        }
        
// end 
Save file.

3) Open link_summary.tpl in your /templates/template/ folder
find {if $pagename neq "story"} <a href="{$story_url}" style="text-decoration:none">
It is right after the section with extra fields.Change to wollowing:

{if $long_content eq true}{if $pagename neq "story"} <a href="{$story_url}" style="text-decoration:none"> .....{/if}{/if}

You can save. Thats all. Consider using picture just like me but it depends on you at all.
Reply With Quote
  #2 (permalink)  
Old 12-02-2007, 04:43 PM
New Pligger
Pligg Version: 9.8.2
Pligg Template: yget
 
Join Date: Aug 2007
Posts: 18
Absolutely perfect, thank you!
Reply With Quote
  #3 (permalink)  
Old 12-02-2007, 04:58 PM
New Pligger
Pligg Version: 9.8
Pligg Template: yget
 
Join Date: Nov 2007
Posts: 24
great! thank you
Reply With Quote
  #4 (permalink)  
Old 01-12-2008, 06:18 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
I have experienced a great issue when users CAN add some HTML tags to story content. The problem is that if html tags are used and story content is cutted to 165 characters, there will NOT be endtags.

What does it mean practically?
Big problem. Not only page is not valid, every story content will be then bold,italic or underlined also (depends on allowed tags).

Solution:
1) Disallow HTML tags in story.
2) Use my new hardcoded update.

It is funny that original idea was pretty simple but this is quite difficult because we need alternative story content with closed html tags.

Update:
Replace original code in link.php
PHP Code:
  // if link content < 160 chars then no "MORE" link
        
if (strlen($this->content)>165){
        
$smarty->assign('long_content',true);          
        }
        
// end 
with
PHP Code:
         //*********************************************************************
        //READ MORE ADDON START
        
        // if link content < 160 chars then no "MORE" link
        
if (strlen($this->content)>165){
        
//find if text has unclosed tags
                              
        
$cutted_contentutf8_substr($this->content,0,165);
        
        
//shortest tag can be at least 3 chars long
        
for ($i=$i<strlen($cutted_content)/$i++) {     
    
       
//find html tag if previous tag position number was lower 
          
if ($gtpos <= $i*3) {         
          
$ltpos=stripos($cutted_content,"<",$i*3);
          
$gtpos=stripos($cutted_content,">",$i*3);
          }else {
           
           
$ltpos=stripos($cutted_content,"<",$ltpos+1);
           
$gtpos=stripos($cutted_content,">",$gtpos+1);  
        
            } 
            
//if tag was detected  
            
if ($ltpos>-&& $gtpos>-1){
          
          
$tag=substr($cutted_content,$ltpos+1,$gtpos-$ltpos-1);
          
// exclude empty tags and end tags    
          
if(strlen($tag)>&& substr($tag,0,1)!="/"){       
          
$count[$tag]++;
          
$tagname[]=$tag;
          }
          }else {
          
//no more tags, no more cycles needed  
          
break;   
          }  
          }
          
          
          
//check if tag has its own closetag
        
if ($tagname) {  
          
          
$origtext=$cutted_content;  
       
          foreach (
$tagname as $tagn) {
          
          
$cltag=stripos($origtext,"</$tagn>");
          if (
$cltag ==false){
            
$addclosetags[]="</$tagn>";  
            }else {
            
$origtext substr($origtext,0,$cltag).substr($origtext,$cltag+strlen("</$tagn>"));   
            }            
         }
          if (
$addclosetags){
            
$addclosetagsarray_reverse($addclosetags);
              
$updated_content=$cutted_content;        
                  foreach (
$addclosetags as $at){
                       
$updated_content .=$at;
            }
        
         
        
$smarty->assign('updated_content',$updated_content);
        
$smarty->assign('add_closetags',true);
           } 
//update v 0.2
        
}
        
$smarty->assign('long_content',true);
        
        }                                                                       
        
//READ MORE ADDON END
        //********************************************************************** 
Now open link_summary.tpl in your templates/yget/ folder and find
Code:
    {if $show_content neq 'FALSE'} ...something...{/if}
Replace it with:
Code:
{if $show_content neq 'FALSE'}
                    
                    {if $add_closetags eq true}
                    {if $pagename neq "story"} 
                    {$updated_content}
                    {else}
                    {$story_content}
                    {/if}
                    {else}
                    {$story_content}
                    {/if}
Now everything should work smoothly

Last edited by AnAlienHolakres3; 01-21-2008 at 05:15 AM. Reason: Update 0.2
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problem with display of link content when read more is clicked pchitrada Questions and Comments 4 06-30-2008 05:54 PM
[SOLVED] &quot;Read More&quot; Link to read full article does not work sipoyraj Questions and Comments 2 01-14-2008 01:29 AM
Understanding the Link Cache in read() revolver Questions and Comments 0 10-25-2007 04:01 PM
Why is the "Read more" link active when there's nothing more to read? nothingman Questions and Comments 0 09-12-2007 02:15 PM
Sometimes read more link is not correct daone Questions and Comments 14 02-16-2007 12:50 PM


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