You are here:  » How to pull logos from another domain v12/10B


How to pull logos from another domain v12/10B

Submitted by Convergence on Fri, 2016-04-08 02:19 in

Greetings David - Hope all is well with you.

We need to be able to pull logos, not from a PT install, but from a directory on another domain.

We don't want to have to recode every instance of the HREF in the template files. Editing the advanced.config file doesn't seem to work because the $config_baseHREF (in config.php) is set to the install name and coded throughout the template.

We tried various rewrite rules in .htaccess with no success.

Any ideas on our heavily modified version v12/10B?

Thanks, David!

Submitted by support on Fri, 2016-04-08 09:13

Hi there,

All well thankyou!

Pulling the images from an external domain is no problem but it is unlikely that you will be able to use the file_exists() check to determine whether to display the logo or just the merchant name however if the sites are on the same server and there is file system access between them this could be re-introduced - just let me know.

However to replace the conditional with directly rendered links to the logo files on the external site, edit your html/prices.php and locate the following code where the logo, or merchant name if not exists is displayed:

<?php print (file_exists("logos/".$product["merchant"])?"<img alt='".$product["merchant"]."' src='".$config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"])."' />":$product["merchant"]); ?>

...and REPLACE with:

<?php print "<img alt='".$product["merchant"]."' src='http://www.example.com/logos/".str_replace(" ","%20",$product["merchant"])."' />";

...where www.example.com is the external domain and logos the folder containing the logo files. Naming would be as per the existing method, e.g. exact match of the merchant name, including spaces.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2016-04-08 12:26

Thanks, David.

The sites are on the same server.

Is there a way to pull them without editing template files?

Submitted by support on Fri, 2016-04-08 12:33

Hi,

As long as there is shared file system access between the sites then you could replace the logos/ folder of the Price Tapestry installation with a symbolic link to the folder containing the images (which should contain nothing but images of course)

Assuming logos in the folder;

/home/username/www.example.com/logos/

...and Price Tapestry installation is at

/home/username/www.example.net/

Remove (or rename) the logos/ folder in the Price Tapestry installation and then replace it with a symbolic link to the alternative folder, for example (after removing or renaming)

cd /home/username/www.example.net/
ln -s /home/username/www.example.com/logos/ logos

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2016-04-08 16:16

Thank you, David.

Computer Amish at the moment.

Where does this go?

cd /home/username/www.example.net/
ln -s /home/username/www.example.com/logos/ logos

Submitted by support on Sat, 2016-04-09 09:32

Hi,

They're system commands that would need to be entered from the command line in order to set-up the symbolic link between the logos folder of the Price Tapestry installation and the logos folder of the other site on the same server...

Command line access is normally via SSH (Secure Shell) using a client such as PuTTY however if you're not familiar with command line access and you have managed hosting they should be able to create the link for you, and that should enable you to have logos come from the other folder without having to modify your html/ files...

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Sat, 2016-04-09 12:46

Thanks again, David!

Will see about getting the data center to do this for us.

Have a great weekend!

Submitted by Convergence on Tue, 2016-04-12 12:59

Hi David,

Decided to edit template files.

However, since we display some merchant logos on our index.php page (non-PT), we will need to edit our /html/banner.php file.

<div class='banner'>
<?php
if (strpos($_SERVER["PHP_SELF"],"search.php"))
{
  if ($parts[0]=="merchant")
  {
    if (file_exists("../logos/".$parts[1]))
    {
      print "<img src='/logos/".$parts[1]."'class='logoleft' />";
    }
    if (file_exists("../merchantinfo/".$parts[1].".html"))
    {
      print file_get_contents("../merchantinfo/".$parts[1].".html");
    }
  }
}
?>
</div>
<br clear='both' />
<div class='banner'>
 <?php if (isset($banner["h2"])) : ?>
   <h2><?php print $banner["h2"]; ?></h2>
 <?php endif; ?>
 <?php if (isset($banner["h3"])) : ?>
   <h3><?php print $banner["h3"]; ?></h3>
 <?php endif; ?>
</div>

Any help there would be greatly appreciated.

Thank you, again!

Submitted by support on Tue, 2016-04-12 13:40

Hi Convergence,

Where you have this code:

    if (file_exists("../logos/".$parts[1]))
    {
      print "<img src='/logos/".$parts[1]."'class='logoleft' />";
    }

...REPLACE with just:

    print "<img src='http://www.example.com/logos/".$parts[1]."'class='logoleft' />";

Where http://www.example.com/logos/ is the fully qualified URL of the logos folder on the external site as before...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Tue, 2016-04-12 13:44

Hi David,

Thank you for your stellar support!

However, figured out a much easier way to accomplish all this:
Modify the config.advanced.php file
$config_logoBaseHREF = "http://www.example.com/";
(keeping the same file hierarchy on the source domain as the PT install.

So far this seems to be working... :)

Submitted by support on Tue, 2016-04-12 13:47

Yes, that will be fine wherever $config_logoBaseHREF is used in the html/ files - no problem!

Cheers,
David.
--
PriceTapestry.com