You are here:  » Multiple installation


Multiple installation

Submitted by wesse249 on Sun, 2015-05-10 08:35 in

Hello David,

I have some questions about Multiple installation. I read several post but it isn't clear to me.

I have one major installation: www.example.com

- I changed in config.advanced.php $config_feedDirectory = "../feeds/"; to $config_feedDirectory = "/home/example/public_html/feeds/";

I have setup a subdomain: http://subdomain.example.com

- This subdomain has also the same config.advanced.php file from above.
- subdomain is the merchant with his own feed.

At this moment the main site example.com has a lot of feeds for it's own. This feeds i remove. I want to setup the site with subdomains for every merchant. But when a visitor goes to the main site aanbiedingvinden.nl it must be possible to search from here in all subdomains.

Question:

1 How can i only show the merchant subdomain on http://subdomain.example.com. Now al the feeds are showed. When i have to do this with a filter is it possible to this once? So i mean i don't have to edit every feed?
2 I read about to give every merchant installation his own TablePrefix. But i think i go to minimal 100 merchant installations. So is the database then not becomming very big?
3 How can i give the products in the subdomain installation the canonical url from the subdomain. And when somebody search from the main site example.com the products also have the canonical url from the subdomain?

I hope you can help me. Thanks,

Greetings JR

Submitted by support on Mon, 2015-05-11 11:18

Hello JR,

In this scenario I would actually keep everything in the one database, so your subdomain.example.com installations (where "subdomain" is a merchant name) use exactly the same configuration as the main site www.example.com.

However, it is straight forward to filter down each subdomain.example.com installation so that only products for the "subdomain" merchant are revealed by category / brand A-Z and search results.

Rather than having to rely on the subdomain name being an exact merchant name match, instead what I would suggest is creating a .txt file in each subdomain containing the merchant name filter to use for that installation, e.g.

merchant.txt

Merchant Name

Now to have the results filtered for that merchant in each case, apply changes as follows;

Brand A-Z
In brands.php look for the following code at line 6:

  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";

...and REPLACE with:

  $merchant = trim(file_get_contents("merchant.txt"));
  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY brand";

Category A-Z
In categories.php look for the following code at line 6:

  $sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";

...and REPLACE with:

  $merchant = trim(file_get_contents("merchant.txt"));
  $sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY category";

Search Results
In search.php look for the following code at line 28:

  $priceWhere = "";

...and REPLACE with:

  $merchant = trim(file_get_contents("merchant.txt"));
  $priceWhere = " AND merchant='".database_safe($merchant)."' ";

To make canonical URLs as described, firstly, add a lookup table to config.advanced.php associating the actual subdomain used for each merchant name:

  $config_subdomains["Merchant Name One"] = "merchant-name-one";
  $config_subdomains["Merchant Name Two"] = "merchant-name-two";
  // etc..

Then in html/header.php (all installations), look for the following code at line 26:

  </head>

...and REPLACE with:

  <?php
  if (isset($product["products"]))
  {
    print "<link
      rel='canonical'
      href='http://".$config_subdomains[$product["products"][0]["merchant"]].".example.com".tapestry_productHREF($product["products"][0])."' />";
  }
  ?>
  </head>

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2015-05-11 14:29

Hello David,

I can't get it to work.

I made the replacements but for example the category page is now a white page.

Maybe your can look?

{code saved}

in public_html you find subdomain/map: babyslofjes

Merchant name in de database is: Baby slofje

Thanks Jan Roel

Submitted by support on Mon, 2015-05-11 14:43

Hello Jan,

All it was, is the modification to categories.php included part of the original code at the end of the line, after the ";" character - working fine now!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2015-05-11 18:59

Hello David,

Thanks for the great support.

I have a few other little questions and then it's finished.

1) On my homepage i show random 18 products. In my index i have this code:

$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 18";

Is it possible to show only the random products of merchant/subdomain?

2) On top of al my pages i have a logo. I have this piece of code placed in header_after.php:

<br><div style='text-align: center'>
<a href="/index.php" target="_self"><img src="/images/logo.png" /></a>
</div>

Is it possible to place the merchant name before my own logo? Like this:

<a href="/index.php" target="_self">HERE MERCHANT logo<img src="/images/logo.png" /></a>

3) I'd like to have some text under the search box and only on the homepage. is this possible?

4) This is my title tag:

<title><?php print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset):"")." - example.com"?></title>

When i click for example on a product then the title is like this: product - example.com

But now the problem when i go the the homepage then you see only this: - example.com
Is it possible to place the merchant name before the - only on the home page? Like this: merchant name - example.com

Thank you very much.

Greetings Jan Roel

Submitted by support on Tue, 2015-05-12 08:06

Hello Jan,

Re 1;

In place of the code identified;

  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 18";

...use:

  $merchant = trim(file_get_contents("merchant.txt"));
  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 18";

Re 2;

  <?php $merchant trim(file_get_contents("merchant.txt")); ?>
  <a href="/index.php" target="_self">".$merchant." <img src="/images/logo.png" /></a>

Re 3;

In html/searchform.php, you can add content conditional for display on the home page (index.php)
only as follows:

Look for the follwing code at line 43:

  </form>

...and REPLACE with:

  </form>
  <?php if (strpos($_SERVER["PHP_SELF"],"index.php")!==FALSE): ?>
    <!-- content below search form on home page only here -->
  <?php endif; ?>

Re 4;

REPLACE the code identified with:

<?php
  if (!isset($header["title"]))
  {
    $header["title"] = trim(file_get_contents("merchant.txt"));
  }
?>
<title><?php print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset):"")." - example.com"?></title>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2015-05-12 19:48

Hello David,

When i add this one to the logo:

  <?php $merchant trim(file_get_contents("merchant.txt")); ?>
  <a href="/index.php" target="_self">".$merchant." <img src="/images/logo.png" /></a>

Then i only see this ".$merchant." in front of the logo and no real image.

And antother question:

On the merchant pages the url of merchant are like this: http://subdomain.example.com/merchant/Dekbed-discounter/
When i click on this one i have a white page.

And on the main site like this: http://www.example.com/merchant/Dekbed-discounter/
When i click on this one i go to the merchant page of the main site.

I like to have on the main and merchant pages the url's like the subdomain: http://merchant.example.com.

Is this possible?

Thanks Jan Roel

Submitted by support on Wed, 2015-05-13 08:21

Hello Jan,

Regarding $merchant appearing literally, PHP tags are actually required - have a go with:

  <?php $merchant trim(file_get_contents("merchant.txt")); ?>
  <a href="/index.php" target="_self"><?php print $merchant?> <img src="/images/logo.png" /></a>

Regarding http://www.example.com/merchant/Dekbed-discounter/ causing a white page, that sounds like a PHP error is occurring but is not being displayed (which is the normal setting for production servers). search.php is the script executed by that URL, so if you could double check the modification to this file described in my first reply and if all looks OK you can enable error messages by adding the following to the end of config.advanced.php (just before the closing PHP tag)

  ini_set('display_errors','on');
  error_reporting(E_ALL);

If there is no difference, double check also that .htaccess is in place correctly in the subdomain installation(s) as that is also necessary for /merchant/merchant-name/ URLs to work properly. If you're still not sure let me know and I'll check that out further with you of course.

To make Merchant A-Z links on main site to subdomain site, in merchants.php on main site look for this code at line 21:

  $item["href"] = tapestry_indexHREF("merchant",$product["merchant"]);

...and REPLACE with:

  $item["href"] = "http://".$config_subdomains[$product["merchant"]].".example.com".tapestry_indexHREF("merchant",$product["merchant"]);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 09:09

Thanks David,

I think i'm almost ready.

One problem with merchant logo before my own logo:

<?php $merchant trim(file_get_contents("merchant.txt")); ?>
<a href="/index.php" target="_self"><?php print $merchant?> <img src="/images/logo.png" /></a>

The logo is only showed on my main site and not on the merchant subdomain. This comes maybe through the subdomain installation? Logo isn't upload to the subdomain? Is it possible that a subdomain installation looks for the logo in the main site installation?

One other latest question:

On merchants.php i changed the code to

$item["href"] = "http://".$config_subdomains[$product["merchant"]].".example.com";

Where i removed by myself: .tapestry_indexHREF("merchant",$product["merchant"]) so i have only the merchant sub domain url.

I like to have the same merchants.php on all merchant and the main installation. But for every new merchant installation i add a new rule $config_subdomains["merchant"] = "merchant"; to config.advanced.php which i upload to the new merchant installation and main site.
I don't upload it to all other merchant installations so here occurs my problem. Not every url is okai because i didn't uploaded the file to all merchant installations.

My question: is it possible that the merchant installations always look to the config.advanced.php in the main installation? It save me a lot of time.

Thanks Jan Roel

Submitted by support on Wed, 2015-05-13 10:14

Hello Jan,

For the merchant logo to be loaded from main installation from all subdomains, use the fully qualified path to the logo image in the src attribute of the image tag, for example:

<?php $merchant trim(file_get_contents("merchant.txt")); ?>
<a href="/index.php" target="_self"><?php print $merchant?> <img src="http://www.example.com/images/logo.png" /></a>

Sure you can have all installations load the same config.advanced.php from main installation. In the main installation, go to /admin/ and then Tools > Support Info and note the "Install Path", e.g.

/home/username/public_html/

Add to this config.advanced.php to get the full path to config.advanced.php e.g.

/home/username/public_html/config.advanced.php

And then edit includes/common.php and look for the following code at line 6:

    require("config.advanced.php");

...and REPLACE with:

    require("/home/username/public_html/config.advanced.php");

And finally the following code at line 14:

    require("../config.advanced.php");

....REPLACE with:

    require("/home/username/public_html/config.advanced.php");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 10:32

Hi,

Sorry i think i explained it wrong.

see here i added merchant in front of my own logo: http://subdomain.example.com/

with this code:

<?php $merchant trim(file_get_contents("merchant.txt")); ?>
<a href="/index.php" target="_self"><?php print $merchant?> <img src="http://www.example.com/images/logo.png" /></a>

You see the text: Merchant Name and then my logo.

I'd like to see here the logo from the Detafelvan10. I added this logo allready to my main site where you can see it. But it doesn't show on the merchant site.

Main site with logo: http://example.com/merchant/

Submitted by support on Wed, 2015-05-13 11:14

Hello Jan,

Sure - no problem to use merchant logo from main site as site logo, have a go with:

<?php $merchant trim(file_get_contents("merchant.txt")); ?>
<a href="/index.php" target="_self"><?php print $merchant?> <img src="http://www.example.com/logos/<?php print $merchant?>" /></a>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 11:19

Hi,

Here is problem the logo doesn't show up.

{link saved}

Submitted by support on Wed, 2015-05-13 11:27

Hello Jan,

I viewed the source and notice it still shows "example.com" from my example code - replace this with your main domain name and that should be all it is...

Set-up is looking great!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 12:42

Hello,

Thanks it works.

One last thing. On the productpage of a merchant website you have the block with logo / price / visit store info.

Here is the logo not showed up. Example:

{link saved}

Submitted by support on Wed, 2015-05-13 12:55

Hello Jan,

Best thing to do would be to, just like the in main logo, load merchant logos from the main site.

To do this, in html/prices.php look for the following code at line 49:

  <?php if (file_exists("logos/".$product["merchant"])): ?>

...and REPLACE with:

  <?php if (TRUE): ?>

And finally the following code at line 51:

<td class='pt_pr_mlogo'><a href='<?php print tapestry_buyURL($product); ?>'><img alt='<?php print htmlspecialchars($product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print $config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]); ?>' /></a></td>

...and REPLACE with:

<td class='pt_pr_mlogo'><a href='<?php print tapestry_buyURL($product); ?>'><img alt='<?php print htmlspecialchars($product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print $config_baseHREF."http://www.example.com/logos/".str_replace(" ","%20",$product["merchant"]); ?>' /></a></td>

(replacing example.com with your domain name as before)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 13:21

ha almost.

He places the word logo after the merchant name see {link saved}

I changed example in my name.

Gr JR

Submitted by support on Wed, 2015-05-13 13:34

Hello Jan,

Sorry about that I made a mistake in the REPLACEment, it should not use $config_baseHREF. Have a go with the following:

<td class='pt_pr_mlogo'><a href='<?php print tapestry_buyURL($product); ?>'><img alt='<?php print htmlspecialchars($product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print "http://www.example.com/logos/".str_replace(" ","%20",$product["merchant"]); ?>' /></a></td>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 13:53

David,

Thanks no problem (-: works great now.
Can i use code above also for merchants.php page on the merchant subdomains? Because here are the logo's als not showed up.

{link saved}

Submitted by support on Wed, 2015-05-13 14:33

Hello Jan,

Sure, to use the main site merchant logos for merchants.php look for the following code beginning at line 16:

    if (file_exists("logos/".$product["merchant"]))
    {
      $item["logo"] = $config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]);
    }

...and REPLACE with just:

  $item["logo"] = "http://www.example.com/logos/".str_replace(" ","%20",$product["merchant"]);

(change example.com to your domain name as before)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2015-05-13 20:37

Thank you David for the really great support!

Submitted by wesse249 on Fri, 2015-05-15 10:43

How is the best way to style this code in the newest version:

  </form>
  <?php if (strpos($_SERVER["PHP_SELF"],"index.php")!==FALSE): ?>
    <!-- content below search form on home page only here -->
  <?php endif; ?>

Thanks Jan Roel

Submitted by support on Fri, 2015-05-15 10:48

Hello Jan,

That's all current - will work fine in 15/01A!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2015-05-25 18:10

Hi David,

A multiple instalation question about sitemaps.

As you know i have a main site www.example.com and al the merchants are on subdomains. But all using the same database.

When i go to http://www.example.com/sitemap.php you al the site map url's of my merchants.

Question 1:
Is it possible to make here url's of subdomain sitemaps? Like:

<sitemap>
<loc>
http://merchant1.example.com/sitemap.php?filename=merchant1.xml
</loc>
<lastmod>2015-05-25</lastmod>
</sitemap>
<sitemap>
<loc>
http://merchant2.example.com/sitemap.php?filename=merchant2.csv
</loc>
<lastmod>2015-05-25</lastmod>
</sitemap>

Question 2
When i go to a merchant subdomain and visit the sitemap page. I see here also all the merchant site map links. see {link saved}
Does this affect google. Because these merchants aren't on available on these subdomains. Or is it better to remove this page? So yes what is the best way to do this?

Question 3
Do i have to add al subdomain sitemaps in google webmaster. Or is only the the sitemap of question 1 enough?

Question 4

I'd like to use your ping script:

<?php
  
require("../includes/common.php");
  
$sitemap "http://".$_SERVER["HTTP_HOST"].$config_baseHREF."sitemap.php";
  
$pings = array();
  
$pings[] = "http://www.google.com/webmasters/sitemaps/ping?sitemap=%SITEMAP%";
  
$pings[] = "http://www.bing.com/ping?sitemap=%SITEMAP%";
  
// add any additional search engine PING URLs here
  
foreach($pings as $ping)
  {
    
$ping str_replace("%SITEMAP%",$sitemap,$ping);
    
file_get_contents($ping);
  }
?>

What i have to changed for the subdomains sitemap pings.

Greetings Jan Roel

Submitted by support on Tue, 2015-05-26 08:44

Hello Jan,

A sitemap index cannot "officially" (according to the specification) link to a sitemap URL that is on a subdomain. Google apparently have a concession in that a sitemap index served from the root domain e.g.

http://example.com/sitemapindex.xml

- and specifically not http://www.example.com/sitemapindex.xml

...can link to

http://subdomain.example.com/sitemap.xml

However, since this isn't something that is part of the specification, I would actually suggest in your case simply modifying sitemap.php so that it serves just the sitemap of that installation, based on the merchant name from merchant.txt.

To do this, edit sitemap.php and look for the following code at line 80:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE imported > 0 ORDER BY filename";

...and REPLACE with:

  $merchant = trim(file_get_contents("merchant.txt"));
  $sql = "SELECT * FROM `".$config_databaseTablePrefix."feeds` WHERE imported > 0 AND filename IN (SELECT DISTINCT(filename) FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."') ORDER BY filename";

With this in place, check that you only see the index for each subdomain installation's merchant:

http://merchant.example.com/sitemap.php

(an index is still required in case any of your merchants have > 50,000 products)

Regarding ping, a simple modification to loop over your custom $config_subdomains array and ping for each installation can be used - have a go with:

<?php
  
require("../includes/common.php");
  
$pings = array();
  
$pings[] = "http://www.google.com/webmasters/sitemaps/ping?sitemap=%SITEMAP%";
  
$pings[] = "http://www.bing.com/ping?sitemap=%SITEMAP%";
  
// add any additional search engine PING URLs here
  
foreach($config_subdomains as $merchant => $subdomain)
  {
    
$sitemap "http://".$subdomain."example.com".$config_baseHREF."sitemap.php";
    foreach(
$pings as $ping)
    {
      
$ping str_replace("%SITEMAP%",$sitemap,$ping);
      
file_get_contents($ping);
    }
  }
?>

(don't forget to replace example.com with your actual domain name in the above)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2015-05-26 19:03

Thanks david,

Do i place in every subdomain the ping.php or only in the main site?

I only use the con.php of the main site to also import al subdomains because i have one databse. When i use this con.php are all my subdomains pinged with this script?

Submitted by support on Tue, 2015-05-26 20:36

Hello Jan,

You only need to run ping.php once from main site.

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2015-07-04 11:10

Hi David,

On my subdomain home pages i have the featured page lay-out like: {link saved}

Is is possible to have this lay-out also on the category, searchresult and brandpages?

Submitted by support on Sat, 2015-07-04 11:25

Hello Jan,

You can use html/featured.php almost as a drop-in replacement for html/searchresults.php with just a couple of minor modifications.

Make a backup of your current html/searchresults.php so that you can revert easily and then copy html/featured.php and save as html/searchresults.php.

Firstly, remove the "Featured Products" title bar at line 7:

  <h2><?php print translate("Featured Products"); ?></h2>

...and finally look for the following code at line 11:

  <?php foreach($featured["products"] as $k=> $product): ?>

...and REPLACE with:

  <?php foreach($searchresults["products"] as $k=> $product): ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sun, 2015-07-05 13:06

Hello David,

Thanks. Is it possible to change the width? Because when you look here you see that the product are smaller then the filter block..

I'd like to have 5 product on a row and bigger images.

{link saved}

Thanks Jan Roel

Submitted by support on Mon, 2015-07-06 08:33

Hello Jan,

Having made your new html/searchresults.php from a copy of html/featured.php, to adjust to full width first look for both instances of this code which creates the margin to centralise the Featured Products;

<div class='medium-3 large-2 columns'>&nbsp;</div>

DELETE that code from lines 3 / 63, and then look for the following code around line 9:

Having removed the Featured Products title, you should now have the following code beginning at around line 5:

  <div class='medium-6 large-8 columns'>
    <ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-4">

...so if you REPLACE with:

  <div class='small-12 columns'>
    <ul class="small-block-grid-2 medium-block-grid-5">

...that will give you full width, 2 columns on small (mobile) display and 5 columns on medium and upwards.

To increase the image size, if you are happy to increase the image size of Featured Products also, then in html/default.css simply adjust the height value in the style definition for .pt_fp_image beginning at line 32:

  .pt_fp_image {
    border: 0;
    height:100px;
    max-width:none;
  }

Otherwise, edit your new html/searchresults.php and replace pt_fp_image with pt_sr_image and then add the required height attribute to the .pt_sr_image style definition at line 129 in default.css

  .pt_sr_image {
    border: 0;
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2015-08-17 21:04

Hello David,

I have installed everything on subdomains.

This is my config.advanced.php

$config_subdomains["Baby slofje"] = "babyslofjes";
$config_subdomains["Bedden"] = "bedden";
$config_subdomains["Boxsprings"] = "boxspring";

["Baby slofje"] = The merchant name
"babyslofjes"; = The subdomain

I like to have the subdomainname in the title tag. is this possible?

<?php
 
print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset):""); 
?>
- HERE SUBDOMAIN NAME.example.nl

Greeting Jan Roel

Submitted by support on Tue, 2015-08-18 09:12

Hello Jan,

Sure - have a go with something like;

<?php
 
print (isset($header["title"])?htmlspecialchars($header["title"],ENT_QUOTES,$config_charset)." - ":"").$config_subdomains[$merchant].".example.nl";
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Fri, 2015-09-25 21:19

Hello David,

I added this to my homepage:

  <?php if (strpos($_SERVER["PHP_SELF"],"index.php")!==FALSE): ?>
    <!-- content below search form on home page only here -->
  <?php endif; ?>

But how can i programm it that on the homepage is showed text A and on the category page text B?

Thanks Jan Roel

Submitted by support on Sat, 2015-09-26 11:01

Hello Jan,

elseif / case could be used but the easiest thing to do would be just to duplicate the section but for categories.php e.g.

  <?php if (strpos($_SERVER["PHP_SELF"],"index.php")!==FALSE): ?>
    <!-- content below search form on home page only here -->
  <?php endif; ?>
  <?php if (strpos($_SERVER["PHP_SELF"],"categories.php")!==FALSE): ?>
    <!-- content below search form on category A-Z page only here -->
  <?php endif; ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Thu, 2015-10-15 11:41

Hello David,

I work with subdomains. In config.advanced.php i put this:

{code saved}

Than i place a merchant.txt in te root with the feed/shop name.

On my home page i show al merchant with a direct link to their subdomain. Like this:

if ($config_useRewrite)
{
$item["href"] = "http://".$config_subdomains[$product["merchant"]].".example.com";
}
else

This file called merchant_frontpage.php

Now my question:

I have also some normal domainnames which i'd like to link to my basic site. So subdomain = normal domain. In config.advanced.php i make it like this:

$config_subdomains["Test website"] = "example.com";

Now my problem. On my merchant_frontpage.php the link to the domain sound like this:

example.com.example.com

Doe you have a solution when it's a subdomain he show the link to the subdomain and when a normal url he show the normal url?

Thank You very much.

JR

Submitted by support on Thu, 2015-10-15 12:13

Hello JR,

As long as your main website is served by www.example.com if you use:

  $config_subdomains["Test website"] = "www";

...that should be all you need to do!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Thu, 2015-10-15 13:59

Hello David that is correct. But i use www for my main website. Instead of a subdomain i have also normal url like this:

{code saved}

My problem is that when i use normal url between the subdomains on my merchant_frontpage.php is get url to the site:

http://www.example.com.example.com and it must be http://www.example.com

So when i use a subdomain the site muste use http://subdomain.example.com and when it is a normal url htt://www.example.com

This is the code from merchant_frontpage.php

{code saved}

Submitted by support on Thu, 2015-10-15 15:18

Hello Jan,

I understand - what is actually the case here is that the scope of the $config_subdomains array is really extended and may relate to a full host name instead, in which case it would be best to re-purpose the array to hold the full host name; so "subdomain.example.com" instead of just "subdomain", e.g.

$config_subdomains[""] = "www.example.com";
$config_subdomains["Merchant1"] = "merchant1.example.com";
$config_subdomains["Merchant2"] = "merchant2.example.com";
$config_subdomains["Merchant3"] = "www.example.net";
$config_subdomains["Merchant4"] = "www.example.org";

Notice how Merchant3 / Merchant 4 in above are on different domain names altogether.

With that in place, anywhere that you are currently using $config_subdomains[$product["merchant"]] in conjunction with "example.com", remove the domain name component and just use $config_subdomains[$product["merchant"]] in full, for example, where you have the following (examplified) code from your post:

  $item["href"] = "http://".$config_subdomains[$product["merchant"]].".aanbiedingvinden.nl";

...REPLACE with:

  $item["href"] = "http://".$config_subdomains[$product["merchant"]];

Once all up and working as you would like since $config_subdomains is no longer a strictly accurate description of the variable purpose you might like to go through and change to something more appropriate e.g. $config_hosts but get everything up and running as required before worrying about that..!

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Fri, 2015-10-23 07:24

Hello David,

I work with suddomains. All merchant have their own subdomain page like merchant.website.nl but visitors can also search in the main site in all product of all the merchants.

Every subdomain has it's own installation. But database and feeds are imported from the main site.

But now i have this problem. I think because i work with one database. When i give a search on a merchant subdomain i see the results of al the merchants on my website. I like to see only the searchresults of that subdomain merchant.

Do you know how i can fix this? Because now is not going well google for example.

Thanks JR

Submitted by support on Fri, 2015-10-23 08:13

Hello Jan,

Assuming the above implementation whereby you have a merchant.txt file containing the merchant name for that installation what you could do is read merchant.txt in as a fixed value for merchantFilter in search.php.

To do this, edit search.php and look for the following code at line 14:

  $merchantFilter = (isset($_GET["merchantFilter"])?$_GET["merchantFilter"]:"");

...and REPLACE with:

  $merchantFilter = file_get_contents("merchant.txt");

Similarly, if you use the category / brand A-Z pages, you can limit the results shown by merchant by adding a WHERE clause to the SELECT query. In categories.php look for the following code:

$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";

...and REPLACE with:

$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe(file_get_contents("merchant.txt"))."' ORDER BY category";

And similarly in brands.php

  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";

...REPLACE with:

  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe(file_get_contents("merchant.txt"))."' ORDER BY brand";

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2015-10-24 08:40

thanks works great.

JR

Submitted by wesse249 on Sat, 2015-10-24 08:54

I'd like also to place banners at the different subdomain merchant pages. i'd like to place al the banner for the different merchant in one file in the root.

So i thought i do it like this:

in searchform.php en product.php from html i place this code:

require("/home/public_html/main_root/banners.php");

But now i don't know how to go further. What do i have place in banners.php.

For example when visitor is on the subdomain page of merchant A this banner has to showed:

{code savedd}

And another question is it possible to show the banner also on the product page of the main site of the merchant? with the mainsite i mean the site where all merchant are pladed together {link saved}

Thanks

Submitted by support on Sat, 2015-10-24 09:42

Hello Jan,

In your single banners.php you can check for merchant.txt to get merchant and if not exist then must be main site on /merchant/ page so you can get merchant name from $q (via $parts[1]). Have a go with:

<?php
  $merchant = "";
  if (file_exists("merchant.txt"))
  {
    $merchant = file_get_contents("merchant.txt");
  }
  elseif(isset($parts[1]) && ($parts[0]=="merchant"))
  {
    $merchant = $parts[1];
  }
?>
<?php if ($merchant=="Merchant A"): ?>
  <!-- Merchant A Banner HTML goes here -->
<?php endif; ?>
<?php if ($merchant=="Merchant B"): ?>
  <!-- Merchant B Banner HTML goes here -->
<?php endif; ?>
<?php if ($merchant=="Merchant C"): ?>
  <!-- Merchant C Banner HTML goes here -->
<?php endif; ?>

Include as required on sub-domain installations, and search.php on main installation for banners on merchant search result pages.

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2015-10-24 15:12

Thanks works great on a subdomain. is above also to programm on merchant name.

See {link saved} this is on a subdomain. In the subdomain i have merchant.txt.

I don't have merchant.txt in the root. And i also like to place the banner on the product page of that merchant in my root installation. See this url: {link saved} This is the same product of the same merchant but then in the root.

Submitted by support on Mon, 2015-10-26 10:12

Hello Jan,

To pick up the merchant (of the cheapest price) on the product page, extend the first part of the script above as follows:

<?php
  $merchant = "";
  if (file_exists("merchant.txt"))
  {
    $merchant = file_get_contents("merchant.txt");
  }
  elseif(isset($parts[1]) && ($parts[0]=="merchant"))
  {
    $merchant = $parts[1];
  }
  elseif(isset($product["products"]))
  {
    $merchant = $product["products"][0]["merchant"];
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2015-12-05 10:27

Hello David,

I print some text before my logo with this code:

<?php $merchant trim(file_get_contents("merchant.txt")); ?>
  <a href="/index.php" target="_self"><font color="#12622d"><?php print $config_subdomains[$merchant]; ?></font><img src="/images/logo.png" /></a>

When i look my website on a telefone the image is scales but the text not. Is it possible to scale the text also?

The text is also jumping far away from the image. How can i make the the code so that is not jumping away?

Thanks

Submitted by support on Sat, 2015-12-05 18:41

Hello Jan,

Try enclosing your text within <p> tags however this would be displayed as 'block' by default, so initially have a go with the following to display your custom text inline and with your custom color also, so where you have:

<font color="#12622d"><?php print $config_subdomains[$merchant]; ?></font>

...REPLACE with:

<p style='display:inline;color:#12622d;'><?php print $config_subdomains[$merchant]; ?></p>

Both the style and colour could be moved into .css of course once working by creating a class for the required style.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2015-12-29 10:43

Hello David,

I have a question. All my merchant have their own subdomain. We setup this together.

I have the following question:

When i go to this product:

http://merchant1.example.com/product/test.html

This test product is only and unique for merchant1. But now the problem when i change merchant1 in merchant2 the product is also visible. But this product is not in the assortiment of merchant2.

Do you have a solution how i can solve this? Product for merchant1 only visible for merchant1 and not at subdomain page of merchant2....

Submitted by support on Tue, 2015-12-29 11:07

Hello Jan,

Sure - the merchant name (from merchant.txt) can be added to the SELECT SQL in products.php. In that file, look for the following code at line 12:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($q)."'";

...and REPLACE with:

    $merchant = trim(file_get_contents("merchant.txt"));
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($q)."' AND merchant='".database_safe($merchant)."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2015-12-29 19:47

Hello David,

Thank you very much for the great support. It works great.

How can i also this make this for related products?

    $sql = "SELECT DISTINCT(name),MATCH name AGAINST ('".database_safe($q)."') AS relevance FROM `".$config_databaseTablePrefix."products` ".($ignoreFullText?"IGNORE INDEX (name_2)":"USE INDEX (name_2)")." WHERE ".$where."' AND merchant='".database_safe($merchant)."' ORDER BY relevance DESC LIMIT 10";

Thanks Jan Roel

Submitted by support on Tue, 2015-12-29 19:59

Hello Jan,

Almost - the $where clause generated should be bracketed and then AND'ed with the merchant clause - have a go with:

    $sql = "SELECT DISTINCT(name),MATCH name AGAINST ('".database_safe($q)."') AS relevance FROM `".$config_databaseTablePrefix."products` ".($ignoreFullText?"IGNORE INDEX (name_2)":"USE INDEX (name_2)")." WHERE (".$where.") AND merchant='".database_safe($merchant)."' ORDER BY relevance DESC LIMIT 10";

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2016-11-01 10:32

Hello David,

I have my main website with te regular pricetapestry install. I have also installed above function on subdomains. I have a realy good score with the seo. The subdomains are unique sites of merchants on my main site.

I'd like to make also some unique websites on subdomains of my categories. Like:

television.example.com

On this website i want to show only the categories of products which match with television.

So in above situation i manually fill in the merchant.txt the merchant name. Is it possible to fill in here one or more category names? which then show on the subdomain television.example.com?

Do you know what i mean?

Jan Roel

Submitted by support on Tue, 2016-11-01 11:37

Hello Jan,

Sure, you could do exactly the same thing with a file called category.txt containing the category for that installation.

Then changes to brands.php (from distribution version)

look for the following code at line 6:

  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";

...and REPLACE with:

  $category = trim(file_get_contents("category.txt"));
  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` WHERE category='".database_safe($category)."' ORDER BY brand";

And in search.php

look for the following code at line 28:

  $priceWhere = "";

...and REPLACE with:

  $category = trim(file_get_contents("category.txt"));
  $priceWhere = " AND category='".database_safe($category)."' ";

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2016-11-01 13:22

Hello David,

Thank you is it also possible to add more categories to the text file? For example:

My website is: television.mywebsite.nl

On this website i want to show the categories: Led Television and Plasma Television

Thanks,

Jan Roel

Submitted by support on Tue, 2016-11-01 14:23

Hello Jan,

If you format category.txt as a valid MySQL IN clause, for example

'LED Television','Plasma Television'

...then you can modify brands.php as follows - look for the following code at line 6:

  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER BY brand";

...and REPLACE with:

  $category = trim(file_get_contents("category.txt"));
  $sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` WHERE category IN (".$category.") ORDER BY brand";

And for search.php look for the following code at line 28:

  $priceWhere = "";

...and REPLACE with:

  $category = trim(file_get_contents("category.txt"));
  $priceWhere = " AND category IN (".$category.")";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Thu, 2017-09-21 19:43

Hello David,

On my subdomain websites is have the most viewed products on the index with this code:

  $merchant = trim(file_get_contents("merchant.txt"));
  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."productsmeta` WHERE merchant='".database_safe($merchant)."' ORDER BY views DESC LIMIT 25";

But now i use this modification https://www.pricetapestry.com/node/5662

On the subdomain {link saved} i use the old version of the script on the main site {link saved} the new one.

Can you help me please?

Thanks Jan Roel

Submitted by support on Fri, 2017-09-22 10:28

Hello Jan,

On the main site (new version) where I assume you are not using a merchant.txt file, you can simply use:

  $sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."productsmeta` ORDER BY views DESC LIMIT 25";

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2017-09-23 07:14

Hello David,

Yes i have. But the problem is on the subdomain sites. In de database the productsmeta has no merchant column so the code isn't working.

Jan Roel

Submitted by support on Sat, 2017-09-23 09:11

Hello Jan,

Ah ok - to add `merchant` field to the popular products version from node 5662, first run the following dbmod.php script to add the column;

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."productsmeta`
    ADD `merchant` varchar(255) NOT NULL default ''
  "
;
  
database_queryModify($sql,$rows);
  print 
"Done.";
?>

And then as the modification to products.php:

      $prices["products"] = $rows;
      $merchant = trim(file_get_contents("merchant.txt"));
      $sql = "INSERT INTO `".$config_databaseTablePrefix."productsmeta`
                SET name='".database_safe($product["products"][0]["name"])."',
                    merchant='".database_safe($merchant)."'
                      ON DUPLICATE KEY UPDATE views = views + 1";
      database_queryModify($sql,$result);

And with that in place, your existing SELECT code for most viewed products should work as above...

Cheers,
David.
--
PriceTapestry.com