You are not logged in! If you have not registered yet then click here to join the community!

TOLRA Community Forums


Go Back   TOLRA Community Forums > TOLRA Products (PHP Scripts) > Web Directory Script > Directory Script Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2007, 10:18 AM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
Domain Name Tag

The directory normally draws the URL of the listed site on the detail page with no way of drawing just the domain name, the following mod allows {$domainName} to be placed into templates to draw the domain name.

Create a file called extensioninfo.php with the following:
Code:
<?php

function draw_detailDomainName($data) {
	$u = parse_url($data['url']);
	$data['template']->setValue('domainName', $u['host']);
}
$g_events->addListener('draw_detail', 'draw_detailDomainName');

?>
Note: If the file extensioninfo.php already exists on the server then edit it and add the above code excluding <?php and ?>

Upload extensioninfo.php to the extensions folder on the server. Then add {$domainName} to the detail template t!wddetail.html where you want the domain name shown.
Reply With Quote
Sponsored Links
  #2  
Old 26-06-2009, 08:51 AM
John John is offline
Senior Member
 
Join Date: Jul 2006
Location: Brisbane, Australia
Posts: 125
Can this code be changed so this can be used on the homepage as well, and not only on the detail pages?
Reply With Quote
  #3  
Old 26-06-2009, 09:28 AM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
The short answer is no, but it really depends what you are trying to achieve?
Reply With Quote
  #4  
Old 26-06-2009, 09:48 AM
John John is offline
Senior Member
 
Join Date: Jul 2006
Location: Brisbane, Australia
Posts: 125
Because http://2cvdirectory.com/ accepts listings without a URL, the featured listing on the homepage is not standard. The URL of the listing is only displayed if the listing is for a website.
I'd like to show the domain of the listing without the http:// below the listing, instead of the title which is currently repeated both above and below the listing if there is a URL.
(The title above the listing links to the detail page in case the listing does not have a URL, and the title below the listing links to the website if the listing has a URL)
Reply With Quote
  #5  
Old 26-06-2009, 10:38 AM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
Assuming your index.php has not been modified at all then in index.php find:
Code:
$wd = new wdClient();
$wd->showPage();
Replace it with:
Code:
class myMod extends wdClient {
	function getFeaturedListing(& $tpl) {
		global $g_queryCount;

		if(defined('WDBIDRANK') && WDFEATURE == 1) {
			$order = 'ORDER BY rating DESC';
			$rank = " && rank>'0'";
		}
		else {
			$order = '';
			$rank = WDFEATURE == 2 ? " && rank>'0'" : " && rank>='" . WDHIGHENT . "'";
		}

		// Find number of possible listings, and pick the 1 to show
		$result = @mysql_query("SELECT COUNT({$this->prefix}page.id) FROM {$this->prefix}page,{$this->prefix}category WHERE vis='1'$rank && {$this->prefix}page.linkid='0' && catID={$this->prefix}category.id && nofeature='0'", $this->dbLink);
		$g_queryCount++;
		$row = mysql_fetch_row($result);
		if(($avail = (int)$row[0]) > 0) {
			if(defined('WDBIDRANK') && WDFEATURE == 1)
				$use = mt_rand(0, min(WDBIDRANK, $avail) - 1);
			else
				$use = mt_rand(0, $avail - 1);

			// Get the entry
			$result = @mysql_query("SELECT {$this->prefix}page.id,catID,title,description,url FROM {$this->prefix}page,{$this->prefix}category,{$this->prefix}pageDetail WHERE {$this->prefix}page.id={$this->prefix}pageDetail.id && vis='1'$rank && {$this->prefix}page.linkid='0' && catID={$this->prefix}category.id && nofeature='0' $order LIMIT $use, 1", $this->dbLink);
			$g_queryCount++;

			if(mysql_num_rows($result) == 1) {
				$row = mysql_fetch_row($result);
				$tpl->setValue('featuredListing', 1);
				$tpl->setValue('entryID', $row[0]);
				$tpl->setValue('moreInfo', $this->makeURL('d', $row[0]));
				$tpl->setValue('entryCat', '<a href="' . ($catURL = $this->makeURL('c', $row[1])) . '" class="' . WDSRCHCATCLS . '">' . $this->buildBCTrailLite($row[1]) . '</a>');
				$tpl->setValue('catURL', $catURL);

				$tpl->setValue('entryURL', empty($row[4]) ? '' : '<a href="' . $row[4] . '">' . $row[4] . '</a>');
				$tpl->setValue('entryTitle', $row[2]);
				$tpl->setValue('entryDesc', $row[3]);
			}
		}
	}
}
$wd = new myMod();
$wd->showPage();
The above should leave {$entryURL} blank if there's no URL or output the HTML to make it a link if there is one.
Reply With Quote
  #6  
Old 06-07-2009, 01:48 PM
John John is offline
Senior Member
 
Join Date: Jul 2006
Location: Brisbane, Australia
Posts: 125
It seems you can achieve exactly the same with putting
Code:
<a href="%7b$entryURL%7d">{$entryURL}</a>
below the featured listing. If there is no URL nothing prints, and if there is a URL then it shows
Code:
<a href="http://somelink.com">http://somelink.com</a>
The code above does not seem to remove the http://

I feel like I am missing something (like a few braincells maybe )
Reply With Quote
  #7  
Old 06-07-2009, 07:14 PM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
With the change I gave you you just want {$entryURL} no <a> tag as it the drops the whole <a> if there's no url, or should be.
Reply With Quote
  #8  
Old 07-07-2009, 05:18 AM
John John is offline
Senior Member
 
Join Date: Jul 2006
Location: Brisbane, Australia
Posts: 125
I have added the code to index.php.
In t!wdviewhome.html I only have {$entryURL}.

Let's say I have a listing with URL http://2cvqld.com/page.html

For the moment the php code you wrote will then create the following code:
Code:
<a href="http://2cvqld.com/page.html">http://2cvqld.com/page.html</a>
But the DomainName tag would create this code (if on a detail page):
Code:
<a href="http://2cvqld.com/page.html">2cvqld.com</a>
without "http://" and without the page or folder extension.

Is the code supposed to drop the "http://" and the page or folder extension?

(If the listing has no URL, no code is generated.)
Reply With Quote
  #9  
Old 07-07-2009, 09:12 PM
Paul's Avatar
Paul Paul is offline
Moderator
 
Join Date: May 2006
Location: UK
Posts: 568
Blog Entries: 3
Ah, oops.
Code:
class myMod extends wdClient {
	function getFeaturedListing(& $tpl) {
		global $g_queryCount;

		if(defined('WDBIDRANK') && WDFEATURE == 1) {
			$order = 'ORDER BY rating DESC';
			$rank = " && rank>'0'";
		}
		else {
			$order = '';
			$rank = WDFEATURE == 2 ? " && rank>'0'" : " && rank>='" . WDHIGHENT . "'";
		}

		// Find number of possible listings, and pick the 1 to show
		$result = @mysql_query("SELECT COUNT({$this->prefix}page.id) FROM {$this->prefix}page,{$this->prefix}category WHERE vis='1'$rank && {$this->prefix}page.linkid='0' && catID={$this->prefix}category.id && nofeature='0'", $this->dbLink);
		$g_queryCount++;
		$row = mysql_fetch_row($result);
		if(($avail = (int)$row[0]) > 0) {
			if(defined('WDBIDRANK') && WDFEATURE == 1)
				$use = mt_rand(0, min(WDBIDRANK, $avail) - 1);
			else
				$use = mt_rand(0, $avail - 1);

			// Get the entry
			$result = @mysql_query("SELECT {$this->prefix}page.id,catID,title,description,url FROM {$this->prefix}page,{$this->prefix}category,{$this->prefix}pageDetail WHERE {$this->prefix}page.id={$this->prefix}pageDetail.id && vis='1'$rank && {$this->prefix}page.linkid='0' && catID={$this->prefix}category.id && nofeature='0' $order LIMIT $use, 1", $this->dbLink);
			$g_queryCount++;

			if(mysql_num_rows($result) == 1) {
				$row = mysql_fetch_row($result);
				$tpl->setValue('featuredListing', 1);
				$tpl->setValue('entryID', $row[0]);
				$tpl->setValue('moreInfo', $this->makeURL('d', $row[0]));
				$tpl->setValue('entryCat', '<a href="' . ($catURL = $this->makeURL('c', $row[1])) . '" class="' . WDSRCHCATCLS . '">' . $this->buildBCTrailLite($row[1]) . '</a>');
				$tpl->setValue('catURL', $catURL);

				if(empty($row[4]))
					$tpl->setValue('entryURL', '');
				else {
					$u = parse_url($row[4]);
					$tpl->setValue('entryURL', '<a href="' . $row[4] . '">' . $u['host'] . '</a>');
				}
				$tpl->setValue('entryTitle', $row[2]);
				$tpl->setValue('entryDesc', $row[3]);
			}
		}
	}
}
$wd = new myMod();
$wd->showPage();
I'm sitting in a tent in the middle of a field in the rain at the moment so if it doesn't work let me know.
Reply With Quote
  #10  
Old 08-07-2009, 01:49 PM
John John is offline
Senior Member
 
Join Date: Jul 2006
Location: Brisbane, Australia
Posts: 125
Quote:
Originally Posted by Paul View Post
I'm sitting in a tent in the middle of a field in the rain at the moment so if it doesn't work let me know.
Ah, beautiful England, drizzly one day, rainy the next (you might have to ask Cindy about the pun in that one )

It all works fine now, thanks, obviously the fresh air is doing you good.

I probably should have asked this earlier, but I think the DomainName tag only works on detail pages, right? Is there anyway this can work on category pages as well?
Currently I use extensioninfo.php to draw the listings and part of that file is
Code:
<?php if(!empty($data['url'])) { ?>
<div class="lnkurl"><a href="<?php echo empty($data['url']) ? $data['dirclient']->makeURL('d', $data['id']) : $data['url']; ?>"><?php echo $data['url']; ?></a></div>
<?php } ?>
Just a question at this time, I don't want to spoil your holiday, sitting in the rain . Don't waste any battery power on this one!
Reply With Quote
Reply

Bookmarks

Tags
domain, tag

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

Forum Jump


All times are GMT +1. The time now is 07:24 AM.