Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-25-2008, 10:05 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
Trimming the title

A lot of submissions, especially blogs, when submitted show a title similar to:

Quote:
Website name : page title
The only pertinent information there is the page title, so to clean this up do the following:

open libs/link.php and find:

Code:
if(preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
change to:

Code:
if(preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
            $url_title=trim($matches[1]);
            $url_title = explode(":",$url_title);
            $this->url_title = $url_title[1]; 

}
Thats it.

This only works for new submissions and not current ones, and only submission in the format of Website name : Page title

Tested only in 9.8.2, but the code 9.9.0 looks the same. Backup the above file before applying mod.

Geoserv

Last edited by Geoserv; 01-25-2008 at 10:45 PM..
Reply With Quote
The Following 2 Users Say Thank You to Geoserv For This Useful Post:
  #2 (permalink)  
Old 01-25-2008, 10:17 PM
Constant Pligger
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 164
Thanks: 8
Thanked 24 Times in 16 Posts
Quote:
Originally Posted by Geoserv View Post
A lot of submissions, especially blogs, when submitted show a title similar to:



The only pertinent information there is the page title, so to clean this up do the following:

open libs/link.php and find:

Code:
if(preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
change to:

Code:
if(preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
            $url_title=trim($matches[1]);
            $url_title = explode(":",$url_title);
            $this->url_title = $url_title[1]; 

}
Thats it.

Geoserv

I tried this but, now nothing shows in the title
__________________
iGameit

helpthewriters.com
Reply With Quote
  #3 (permalink)  
Old 01-25-2008, 10:25 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
Please attach your link.php file here so I can have a look.

Geoserv
Reply With Quote
  #4 (permalink)  
Old 01-25-2008, 10:36 PM
Constant Pligger
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 164
Thanks: 8
Thanked 24 Times in 16 Posts
actually

It works sometimes not all of the time.. It will depend on how the websites have it setup.

It worked when it was just title as the address but when they had for example..

What : Something : The story


Something would show up and not story...

I think the code only Eliminates if they have it setup like Website name : the story..

so eliminates everything before the :
Attached Files
File Type: php link.php (35.6 KB, 15 views)
__________________
iGameit

helpthewriters.com
Reply With Quote
  #5 (permalink)  
Old 01-25-2008, 10:41 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
That is true.

Let me try to figure out a solution.

Geoserv.
Reply With Quote
  #6 (permalink)  
Old 01-26-2008, 10:19 AM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
Also when I added the code and tried to add a url that was already submitted I get the following error in the header, This might also happen when you submit a new url but I didn't have a new url to submit and try !

Thanks so much for helping me with this! It's greatly appreciates!

Code:
fp = fsockopen(($this->_protocol == 'https' ? 'tls://' : '') . $this->_host, $this->_port, $errno, $errstr, 20); if(!$this->_fp) {return("BADURL");} fwrite($this->_fp, $req); while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) $response .= fread($this->_fp, 1024); fclose($this->_fp); // split header and body $pos = strpos($response, $crlf . $crlf); if($pos === false) return($response); $header = substr($response, 0, $pos); $body = substr($response, $pos + 2 * strlen($crlf)); // parse headers $headers = array(); $lines = explode($crlf, $header); foreach($lines as $line) if(($pos = strpos($line, ':')) !== false) $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1)); // redirection? if(isset($headers['location'])) { $http = new HTTPRequest($headers['location']); return($http->DownloadToString($http)); } else { return($body); } } } ?>
Attached Files
File Type: php link.php (33.8 KB, 15 views)
Reply With Quote
  #7 (permalink)  
Old 01-26-2008, 06:59 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
I altered your link.php, its attached.

I also added a fix so if a submission is formatted:

Quote:
Website name : Category : Page title
you will still only display the Page Title and the rest is automatically removed.

Geoserv
Attached Files
File Type: php link.php (34.0 KB, 41 views)
Reply With Quote
The Following User Says Thank You to Geoserv For This Useful Post:
  #8 (permalink)  
Old 01-26-2008, 07:00 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
Quote:
Originally Posted by manya1011 View Post
actually

It works sometimes not all of the time.. It will depend on how the websites have it setup.

It worked when it was just title as the address but when they had for example..

What : Something : The story


Something would show up and not story...

I think the code only Eliminates if they have it setup like Website name : the story..

so eliminates everything before the :
Change the code to this so if the format is that or website name: page title it will work:

Code:
if(preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
            $url_title=trim($matches[1]);
            $url_title = preg_split("/:|\-/", $url_title);
            $url_title = array_slice($url_title, -1);
            $this->url_title = $url_title[0];
Geoserv.
Reply With Quote
The Following User Says Thank You to Geoserv For This Useful Post:
  #9 (permalink)  
Old 01-26-2008, 07:12 PM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
Quote:
Originally Posted by Geoserv View Post
I altered your link.php, its attached.

I also added a fix so if a submission is formatted:



you will still only display the Page Title and the rest is automatically removed.

Geoserv
who's link file is this Geo?
Reply With Quote
  #10 (permalink)  
Old 01-26-2008, 07:21 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
Its mine.



Geoserv.
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
Change page title only for story page - Google hadock General Help 12 11-23-2008 07:29 AM
How to change title in browser BillyC "yget" 1 06-21-2008 03:52 PM
Title Issue with Editorials and SEO not2serious General Help 0 12-26-2007 10:25 AM
HELP - Title Tags For Category Pages blaze General Help 2 12-24-2007 08:22 AM
Page Title - Instant Need plum Suggestions 5 10-17-2007 01:57 PM


Search Engine Friendly URLs by vBSEO 3.2.0