Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2007, 10:10 AM
AnAlienHolakres3's Avatar
Pligg Donor
 
Join Date: Jul 2007
Location: Prague
Posts: 117
Thanks: 7
Thanked 112 Times in 40 Posts
Send a message via ICQ to AnAlienHolakres3
Better Read More (in Link)

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.
__________________
=Everything that has a beginnig has an end=
=Nevere stop fighting=

Site: http://www.vselink.org
Reply With Quote
The Following 3 Users Say Thank You to AnAlienHolakres3 For This Useful Post:
  #2 (permalink)  
Old 12-02-2007, 03:43 PM
New Pligger
Pligg Version: 9.8.2
Pligg Template: yget
 
Join Date: Aug 2007
Posts: 18
Thanks: 7
Thanked 1 Time in 1 Post
Absolutely perfect, thank you!
Reply With Quote
  #3 (permalink)  
Old 12-02-2007, 03:58 PM
Casual Pligger
Pligg Version: 9.8
Pligg Template: yget
 
Join Date: Nov 2007
Posts: 32
Thanks: 3
Thanked 0 Times in 0 Posts
great! thank you
__________________
www.moreencore.com - A place to find new music


Pay Per Play advertising - Get paid every time someone visits your site, not just when someone clicks an ad
Reply With Quote
  #4 (permalink)  
Old 01-12-2008, 05:18 AM
AnAlienHolakres3's Avatar
Pligg Donor
 
Join Date: Jul 2007
Location: Prague
Posts: 117
Thanks: 7
Thanked 112 Times in 40 Posts
Send a message via ICQ to AnAlienHolakres3
Better Read More v0.2

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
__________________
=Everything that has a beginnig has an end=
=Nevere stop fighting=

Site: http://www.vselink.org

Last edited by AnAlienHolakres3; 01-21-2008 at 04:15 AM.. Reason: Update 0.2
Reply With Quote
The Following User Says Thank You to AnAlienHolakres3 For This Useful Post:
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
Understanding the Link Cache in read() revolver General Help 0 10-25-2007 03:01 PM
Why is the "Read more" link active when there's nothing more to read? nothingman Off-topic 0 09-12-2007 01:15 PM
Read more link leads to OOPS soulja90 General Help 3 05-17-2007 01:18 AM
read more link @ story.php or link_summery.tpl? DailyResearch General Help 2 05-09-2007 01:12 PM
Sometimes read more link is not correct daone Bug Report 14 02-16-2007 11:50 AM


Search Engine Friendly URLs by vBSEO 3.2.0