You are here:  » enhanced product description


enhanced product description

Submitted by mally on Tue, 2007-07-31 15:20 in

I have a few products which are provided by several companys. is there a way I can add a personlised product description. When products are displayed, the enhanced description (written by me) is shown rather than the one on the feed.. If I've not written an enhanced description the normal cheapest product description is shown.

I could put it in a file or as a seperate feed maybe..

Hope this makes sense

Submitted by support on Tue, 2007-07-31 16:10

Hi Mal,

Yes, the easy way to do this without having to write any database code would be to create a sub-directory of your Price Tapestry installation called "descriptions". Then, within that directory, create text files containing your enhanced descriptions using a filename that exactly matches the product name (including spaces).

You can then pull in that description instead of the cheapest product description by looking for the following code in html/product.php

        <?php if ($mainProduct["description"]): ?>
          <p><?php print $mainProduct["description"]; ?></p>
        <?php endif; ?>

...and changing that as follows:

        <?php
        if (file_exists("descriptions/".$mainProduct["name"]))
        {
          require("descriptions/".$mainProduct["name"]);
        }
        else
        {
          print $mainProduct["description"];
        }
        ?>

Similarly, if you also want to make changes to html/searchresults.php, look for:

<p><?php print substr($product["description"],0,250); ?></p>

...and change this to:

<p>
<?php
if (file_exists("descriptions/".$product["name"]))
{
  require("descriptions/".$product["name"]);
}
else
{
  print substr($product["description"],0,250);
}
?>

Hope this helps!
Cheers,
David.

Submitted by mally on Tue, 2007-11-06 09:31

Hi David

Is is possible to have code such as <p> and <h2> in the description?

The reason I ask is
Coast Magazine
has an enhanced description however it looks a mess without any paragraphs etc

thanks

Mally

Submitted by support on Tue, 2007-11-06 10:36

Hi Mally,

Sure - HTML is stripped by default but you can easily remove the code that does this. In includes/admin.php look for the following code on line 163:

$record[$admin_importFeed["field_description"]] = strip_tags($record[$admin_importFeed["field_description"]]);

To permit HTML, simply comment out or delete this line.

Cheers,
David.

Submitted by mally on Tue, 2007-11-06 12:18

Works Well, thanks!

Mally
Magazine Subscription

Submitted by dbfcs on Tue, 2007-11-06 17:19

Looks good. Nice mod.

Submitted by henk on Wed, 2008-02-27 22:16

yep nice mod, but is it maybee possible to do it with a database.
i already make a table description, with the following fields: :)

sku - with unique number
name - varchar 255
description as text

:)

Thx Henk

Submitted by support on Thu, 2008-02-28 08:30

Hello Henk,

Sure - are you able to modify this table using an existing tool (e.g. phpMyAdmin), so you're just looking for the code to read the associated description and display it as above?

Cheers,
David.

Submitted by henk on Thu, 2008-02-28 08:45

Yes just the code. :)

Thx HEnk

Submitted by support on Thu, 2008-02-28 09:03

Hi Henk,

To pick your database description for the product page; as above look for the following code in html/product.php:

        <?php if ($mainProduct["description"]): ?>
          <p><?php print $mainProduct["description"]; ?></p>
        <?php endif; ?>

...and change this to:

<p>
<?php
$desc_sql = "SELECT description FROM `".$config_databaseTablePrefix."description` WHERE sku='".$mainProduct["sku"]."'";
if (database_querySelect($desc_sql,$desc_rows))
{
  print $desc_rows[0]["description"];
}
else
{
  print $mainProduct["description"];
}
?>
</p>

Similarly, if you also want to make changes to html/searchresults.php, look for:

<p><?php print substr($product["description"],0,250); ?></p>

...and change this to:

<p>
<?php
$desc_sql = "SELECT description FROM `".$config_databaseTablePrefix."description` WHERE sku='".$product["sku"]."'";
if (database_querySelect($desc_sql,$desc_rows))
{
  print $desc_rows[0]["description"];
}
else
{
  print $product["description"];
}
?>
</p>

I've used variables beginning with desc_ in this mod so that it doesn't interfere with other variables already going on in the script...!

Cheers,
David.

Submitted by henk on Thu, 2008-02-28 20:51

Got it, in the backend of the admin a wysiwyg editor :)

link copy and past webpages :)

Thx again
Henk

Submitted by mally on Fri, 2008-02-29 07:28

Hi David

Related to this mod, I have began writing descriptions for quite a few of the products shown on my sites.

Is there a little file you could put together that I can run that would give me a list of products that I have not created a description file for?

This would save me loads of time...

Cheers

Mally

Submitted by support on Fri, 2008-02-29 11:34

Hello Mally,

If you've used the above method of creating a directory called /descriptions/ containing files that match the product name exactly, try something like this:

<?php
  
require("includes/common.php");
  
$dh opendir("descriptions");
  while ((
$file readdir($dh)) !== false)
  {
    
$existing[] = "'".database_safe($file)."'";
  }
  
closedir($dh);
  
$notIn implode(",",$existing);
  
$sql "SELECT DISTINCT(name) FROM `".$config_databaseTablePrefix."products` WHERE name NOT IN (".$notIn.") ORDER BY name";
  if (
database_querySelect($sql,$products))
  {
    foreach(
$products as $product)
    {
      print 
"<p>".$product["name"]."</p>";
    }
  }
?>

Hope this helps!
Cheers,
David.

Submitted by tonyr on Sat, 2008-03-29 16:35

Hi David,

I have tried to apply the mod to the product.php described in this thread and I cannot get it to work.
I want to use text files to create modified product descriptions.
I keep getting blank product descriptions.
I am using the At home with Lewis template.

Here is the coding for the product.php file:

<?php $mainProduct $product["products"][0]; ?>
<h3>
<?php if ($mainProduct["image_url"]): ?>
<a href="<?php print $mainProduct["image_url"]; ?>" title="<?php print $mainProduct["name"]; ?>" rel="lightbox"><img class="fright" width="100" src="<?php print $mainProduct["image_url"]; ?>" alt="<?php print $mainProduct["name"]; ?>" title="<?php print $mainProduct["name"]; ?>" /></a>
<?php endif; ?>
<a href='<?php print tapestry_buyURL($mainProduct); ?>' title='<?php print $mainProduct["name"]; ?>' <?php print javascript_statusBar(translate("Go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a>
</h3>
 <?php
        if (file_exists("descriptions/".$mainProduct["name"]))
        {
          require("descriptions/".$mainProduct["name"]);
        }
        else
        {
          print $mainProduct["description"];
        }
        ?>
<p>
<?php if (count($product["products"]) > 1): ?>
<strong><?php print translate("Best Price"); ?>:</strong>&nbsp;
<?php else: ?>
<strong><?php print translate("Price"); ?>:</strong>&nbsp;
<?php endif; ?>
<?php print $config_currencyHTML.$mainProduct["price"]; ?>&nbsp;<?php print translate("from"); ?>&nbsp;|
              <?php foreach($product["products"] as $priceProduct): ?>
              <?php if ($priceProduct["price"] == $mainProduct["price"]): ?>
                <a href='<?php print tapestry_buyURL($priceProduct); ?>' title='<?php print $priceProduct["merchant"]; ?>' <?php print javascript_statusBar(translate("Go to")." ".$priceProduct["merchant"]); ?>><strong><?php print $priceProduct["merchant"]; ?></strong></a> |
              <?php else: ?>
              <?php break; ?>
              <?php endif; ?>
              <?php endforeach; ?>
</p>
<?php if (isset($mainProduct["extraHTML"])) print $mainProduct["extraHTML"]; ?>
<div class="clear"></div>

Thanks,

Tony

Submitted by support on Sat, 2008-03-29 17:15

Hi Tony,

The mods look OK - the first thing I would do is check that your modified
description files are working - try browsing to:

http://www.example.com/descriptions/product

Also double-check that the filenames match the product names exactly.
If the product have descriptions by default, then the fact that you
are getting blank descriptions indicates that the file_exists()
check is working, but then for some reason they are not being
included with the require() statement.

If in doubt feel free to email me a link to one of your product
pages that should have a modified description and i'll check it
out for you - reply to your reg code or forum registration email
to get me...

Cheers,
David.

Submitted by support on Sat, 2008-03-29 20:39

Hi Tony,

Thanks for your email - I spotted the problem - and have corrected the code above to remove the unnecessary lines.

Cheers,
David.

Submitted by support on Sat, 2008-03-29 20:51

Hi Mal,

Sorted...

Because of the way your prices and product HTML files are combined, the variable had been overwritten by the time this mod was included. To fix it, i've copied the original variable into another variable just for use by this mod.

Cheers,
David.

Submitted by mally on Fri, 2008-04-11 17:39

hi all

some of my items are available from various merchants which have different descriptions.

Would it be possible to show all of the descriptions from the various merchants in the product description? (unless there is a relevant description created by me in the descriptions folder)

Cheers

Mally

Submitted by support on Fri, 2008-04-11 19:31

Hi Mally,

Sure, in place of the following code:

        if (file_exists("descriptions/".$mainProduct["name"]))
        {
          require("descriptions/".$mainProduct["name"]);
        }
        else
        {
          print $mainProduct["description"];
        }

... to display all the descriptions (if yours doesn't exist), you would do something like this:

        if (file_exists("descriptions/".$mainProduct["name"]))
        {
          require("descriptions/".$mainProduct["name"]);
        }
        else
        {
          foreach($product["products"] as $tmp)
          {
            if ($tmp["description"]) print "<p>".$tmp["description"]."</p>";
          }
        }

Cheers,
David.

Submitted by mally on Fri, 2008-04-11 20:08

thanks David, it came back with the following error Warning: Invalid argument supplied for foreach() in /home/magsub/public_html/html/product.php on line 110

Submitted by support on Fri, 2008-04-11 20:45

Hi Mally,

There may have been other modifications made to html/product.php that have replaced the $product["products"] variable by the time it reaches this mod, so I'll have to have a look at your complete file to see what that might be - could you email it to me as an attachment and i'll check it out for you...

Cheers,
David.

Submitted by tonyr on Sun, 2008-04-13 15:52

Hi David,

I have used the mod you describe above to replace the merchant product descriptions with my own descriptions in text files. It works well. Thanks for that.

Here is an example of one of the pages from my site:
http://www.magazineland.co.uk/Classic-Rock.html

Would it be possible to add more content to this page further down the page?

I would like to continue with the product description under the price comparison section but before the "people who bought this also looked at these" section.

The reason is that I would like to keep the price comparison part "above the fold" and surrounded by content.
Cheers,
Tony

Submitted by support on Mon, 2008-04-14 10:40

Hi Tony,

Sure - one way would be to create an "extras" folder which works exactly like the "descriptions" folder. Simply upload files with the exact name of the product; and then include code as shown below within products.php. To insert the extra content after the price comparison section; look for the following line:

  if (isset($prices)) require("html/prices.php");

..and then insert this below:

  if (file_exists("extras/".$q))
  {
    require("descriptions/".$q);
  }

That should do the trick!

Cheers,
David.

Submitted by tonyr on Sun, 2008-04-27 20:39

Thanks David,

That worked great, although I did need to change the word "descriptions" in the second line of the coding to "extras". A typo maybe?

Thanks again for your excellent support.

Tony

Submitted by support on Mon, 2008-04-28 08:06

Ooops yes - a typo!

Cheers,
David.

Submitted by evismaniac on Thu, 2008-05-08 08:36

Hi David,

This thread has been a great help as I was wanting to do my own descriptions so thanks for that!

The only thing I have a question about is this:

I have modified the search results to show my own description txt file, but I would like to limit this to the 250 characters of the original description setup.

I tried had a go by adding the ,0,250, but it doesnt work (I am not very good with php, obviously)

require("descriptions/".$product["name"]

Could you please advise on what I need to add to limit this description?

Many thanks!

Submitted by support on Thu, 2008-05-08 09:54

Hi,

If you want to the limit the original, imported description to 250 characters, the substr() functions needs to go around the following code in html/product.php (line 13 in the distribution):

<p><?php print $mainProduct["description"]; ?></p>

...simply change this as follows:

<p><?php print substr($mainProduct["description"],0,250); ?></p>

Hope this helps!

Cheers,
David.

Submitted by evismaniac on Thu, 2008-05-08 16:10

Thanks for the reply David.

Submitted by support on Thu, 2008-05-08 18:35

Hi,

Sure - easiest way is to read the file into a string instead of print it; and then use substr() on the string.... Try this:

<?php
$filename 
"descriptions/".$product["name"];
if (
file_exists($filename))
{
  
$description "";
  
$fp fopen($filename,"r");
  if (
$fp)
  {
    while(!
feof($fp)) $description .= fread($fp,1024);
    
fclose($fp);
  }
  print 
substr($description,0,250);
}
else
{
  print 
substr($product["description"],0,250);
}
?>

Cheers,
David.

Submitted by evismaniac on Thu, 2008-05-08 19:56

David, you are a php genius! Thanks a lot for your help! :-)

Submitted by Leo on Mon, 2008-05-19 09:18

Hi David,

Is this possible i use this on the searchresults page for the category description works great.

<?php
  if ($product["category"])
  {
    $filename = "categoryinfo/".$product["category"];
    if (file_exists($filename))
    {
      require($filename);
    }
  }
?>

Than i use this to on the same searchresults page for brand description wich works great to.

<?php
  if ($product["brand"])
  {
    $filename = "brandinfo/".$product["brand"];
    if (file_exists($filename))
    {
      require($filename);
    }
  }
?>

Than i use the dropdown menu with category and brandfilter on the searchresults page for category and brands.

What i should want when i select category from dropdownmenu i get the category description than when i choose from the dropdown menu the brand i get the brand description only.
Now i get both descriptions.
Do you think it's easy to get this to work.
Leo

Submitted by support on Mon, 2008-05-19 09:36

Hello Leo,

Sure - when you are on the search page, if it is a category search, the variable $parts[0] will be "category", and when it is a brand search it will be "brand".

Therefore you can look at this variable to decide which info to show. Taking your category section above, the following modification would make it only show on a category search (a search after using the category filter):

<?php
  
if ($product["category"] && $parts[0]=="category")
  {
    
$filename "categoryinfo/".$product["category"];
    if (
file_exists($filename))
    {
      require(
$filename);
    }
  }
?>

And you can do exactly the same for brand... I may be wrong if you are using this code in a different place; but there are probably other variables that can be used in the same way, like $_GET["brandFilter"] and $_GET["categoryFilter"] for example...

Cheers,
David.

Submitted by Leo on Mon, 2008-05-19 10:29

Hello David,

Thanks for the fast reply

I try with the category it didn't work with the dropdownmenu it works if you click on the original normal brand link and from there select the brand than it not showing the category description with your code. But it not showing the category name to in the dropdownmenu.
The brand is not the problem that one dissapear when you not use/select it. The problem is in the category that the description disappear when you select a brand.
Do you have maybe another idea or can you maybe give a example of the $_GET["brandFilter"] and $_GET["categoryFilter"] that one i don't understand?

Thanks
Leo

Submitted by support on Mon, 2008-05-19 11:10

Hello Leo,

Can you email to me the file(s) that you are changing to do this, then I can see what parameters you are using and show you the correct code!

Cheers,
David.

Submitted by mally on Tue, 2008-06-03 22:19

Hello David

Would it be possible to show 8 x random products (only products with an enhanced description) in footer.html

Cheers

Mally

Submitted by support on Wed, 2008-06-04 08:26

Hi Mally,

Have a go with something like this....

<?php
  
// scan the description directory
  
$dirHandle opendir("descriptions/");
  while((
$filename=readdir($dirHandle))!==false)
  {
    if (
substr($filename,0,1) <> "."$filenames[] = $filename;
  }
  
// we now have an array of product names with enhanced descriptions
  // in the $filenames array so we can pick 8 at random using array_rand
  
$randomProducts array_rand($filenames,8);
  
// now display a list of the random products and link to product page
  
print "<ul>";
  foreach(
$randomProducts as $randomProduct)
  {
    if (
$config_useRewrite)
    {
      
$href $config_baseHREF."product/".tapestry_hyphenate(".$randomProduct.");
    }
    else
    {
      
$href $config_baseHREF."products.php?q=".urlencode($randomProduct);
    }
    print 
"<li><a href='".$href."'>".$randomProduct."</a></li>";
  }
  print 
"</ul>";
?>

(PHP tags not required of course if you are already in a PHP section at the point you want to use this code)

This will just print the product names at first, which will at least confirm that the randomisation is behaving as you would like. If you want to display more information (i.e. pulled from the database) for each product, let me know what you want to display as there are various ways to do construct the SQL...

Cheers,
David.

Submitted by mally on Wed, 2008-06-04 17:40

Hi David, ref the above code it produced some links in a column, one of the links were http://www.magazinesubscription.co.uk/product/.434.

The others were the same apart from the numbers.

Cheers
Mally

Submitted by support on Wed, 2008-06-04 17:46

Ah,

My mistake - the array_rand() function returns keys, not actual array values. In that case, the code should be as follows:

<?php
  
// scan the description directory
  
$dirHandle opendir("descriptions/");
  while((
$filename=readdir($dirHandle))!==false)
  {
    if (
substr($filename,0,1) <> "."$filenames[] = $filename;
  }
  
// we now have an array of product names with enhanced descriptions
  // in the $filenames array so we can pick 8 at random using array_rand
  
$randomProducts array_rand($filenames,8);
  
// now display a list of the random products and link to product page
  
print "<ul>";
  foreach(
$randomProducts as $k)
  {
    
$randomProduct $filenames[$k];
    if (
$config_useRewrite)
    {
      
$href $config_baseHREF."product/".tapestry_hyphenate(".$randomProduct.");
    }
    else
    {
      
$href $config_baseHREF."products.php?q=".urlencode($randomProduct);
    }
    print 
"<li><a href='".$href."'>".$randomProduct."</a></li>";
  }
  print 
"</ul>";
?>

Cheers,
David.

Submitted by mally on Wed, 2008-06-04 18:04

Hello David.

Submitted by support on Wed, 2008-06-04 18:10

Ah - that's a bug in this line:

      $href = $config_baseHREF."product/".tapestry_hyphenate(".$randomProduct.");

...it should actually be (including the .html at the end):

      $href = $config_baseHREF."product/".tapestry_hyphenate($randomProduct).".html";

Here's that fix included in the display section of the above code to use a table to display the products in rows instead of using LI...

  $col = 0;
  print "<table>";
  print "<tr>";
  foreach($randomProducts as $k)
  {
    $randomProduct = $filenames[$k];
    if ($config_useRewrite)
    {
      $href = $config_baseHREF."product/".tapestry_hyphenate($randomProduct).".html";
    }
    else
    {
      $href = $config_baseHREF."products.php?q=".urlencode($randomProduct);
    }
    print "<td><a href='".$href."'>".$randomProduct."</a></td>";
    $col++;
    if ($col == 4) // change this number for more or less per row
    {
      print "</tr><tr>";
      $col = 0;
    }
  }
  print "</tr>";
  print "</table>";

Cheers,
David.

Submitted by mally on Wed, 2008-06-04 18:40

Yep, thats perfect, Got it now showing at the bottom of magazine subscriptions

Submitted by mally on Mon, 2008-06-09 21:09

Hello David

Would it be possible to have an enhanced category description.

so basically for Computer Magazines I could have just my own description, so basically create a text like like above?

also, would it be possible to include the meta keyword and description tag in there?

Cheers

Mally

Submitted by support on Tue, 2008-06-10 13:53

Hi Mal,

It's easy to do within search.php by looking at the $parts variable, which will contain "category" in $parts[0] if you are on a category page, with the category name in $parts[1]. As you also want to control meta tags, it's probably easier to do this all inline within the PHP rather than include a text file as is the case in other situations.

In order to set the meta tags, the first bit of code you need to do this needs to go before the header is included; so look for the following line near the bottom:

require("html/header.php");

...and insert this section of code, modified as required ABOVE the above line:

if ($parts[0] == "category")
{
  switch($parts[1])
  {
    // repeat this section, changing for each category
    case "Computer Magazines":
      $header["meta"]["keywords"] = "Your, Computer, Magazines, Keywords, Here";
      $header["meta"]["description"] = "Your computer magazines description here";
      $categoryText = "This is the text you want to display on the computer magainzes page";
      break;
    // end repeat section
  }
}

Then, look slightly lower down for the following code:

if (isset($searchresults))

...and to display your $categoryText, simply insert the following code immediately ABOVE the above line:

if ($parts[0] == "category")
{
  print $categoryText;
}

Cheers,
David.

Submitted by mally on Tue, 2008-06-10 20:56

Hello David

Thanks for the above. I'm wondering if its possible to get it only to show on the first page of the results instead of appearing on all the pages (computer magazines has several pages)

Also, will having about 60 categories using the above code cause problems slowing the site down?

Thanks

Mally

Submitted by support on Wed, 2008-06-11 08:19

Hi Mally,

To apply this to page 1 only, simply change:

if ($parts[0] == "category")

as follows:

if (($parts[0] == "category") && ($page == 1))

There won't be any performance issue with 60 sections - the switch statement can be executed much faster than a database or file system access request.

Cheers,
David.

Submitted by npaitken on Thu, 2008-09-11 08:39

Hi David,

I think I may be having a similar problem to Tony above. I'm also using a PTT template (burning curves).

"Hi Tony, Thanks for your email - I spotted the problem - and have corrected the code above to remove the unnecessary lines."

I've created a test enhanced description text file that matches exactly the product name.
I've modified html/products.php (see below)
I've also modified includes/admin.php to allow HTML tags

But when I navigate to the product page on my site it doesn't seem to have picked up the new enhanced description.

Products.php

<?php $mainProduct $product["products"][0]; ?>
<div id='producttext'>
<h3>
<?php if ($mainProduct["image_url"]): ?>
<img class='bdr' width='200' src='<?php print $mainProduct["image_url"]; ?>' alt='<?php print $mainProduct["name"]; ?>' title='<?php print $mainProduct["name"]; ?>' />
<?php endif; ?>
<a href='<?php print tapestry_buyURL($mainProduct); ?>' title='<?php print $mainProduct["name"]; ?>' <?php print javascript_statusBar(translate("Go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a>
</h3>
<?php
  if (file_exists("descriptions/".$mainProduct["name"]))
   {
     require("descriptions/".$mainProduct["name"]);
   }
   else
   {
     print $mainProduct["description"];
   }
?>
<?php if (isset($mainProduct["extraHTML"])) print $mainProduct["extraHTML"]; ?>
<div class="clear"></div>
<?php $i=0; foreach($product["products"] as $priceProduct): ?>
<?php if (($priceProduct["price"] == $mainProduct["price"]) && ($i==0)):
$bestpricevar="<p><strong>Best Price:</strong> ".$config_currencyHTML.$mainProduct["price"]." ".translate("from")." <a href='".tapestry_buyURL($priceProduct)."' title='".$priceProduct["merchant"]."' ".javascript_statusBar(translate("Go to")." ".$priceProduct["merchant"]).">".$priceProduct["merchant"]."</a>.</p>";
else: ?>
<?php break; ?>
<?php endif; ?>
<?php $i++; endforeach; ?>
</div>
<div class="clear"></div>
</div>
<div class='bodymiddle'>
<?php print $bestpricevar?>
  <table>
    <tr>
      <th><?php print translate("Stockist"); ?></th>
      <th><?php print translate("Catalogue Product Name"); ?></th>
      <th><?php print translate("Price"); ?></th>
    </tr>
    <?php foreach($prices["products"] as $product): ?>
    <tr>
      <td><a href='<?php print $product["merchantHREF"]; ?>' title='<?php print $product["merchant"]; ?>'><?php print $product["merchant"]; ?></a></td>
      <td><a href='<?php print tapestry_buyURL($product); ?>' title='<?php print translate("Visit Store"); ?>' <?php print javascript_statusBar("Go to ".$product["merchant"]); ?>><?php print $product["name"]; ?></a></td>
      <td><a href='<?php print tapestry_buyURL($product); ?>' title='<?php print translate("Visit Store"); ?>' <?php print javascript_statusBar("Go to ".$product["merchant"]); ?>><?php print $config_currencyHTML.$product["price"]; ?></a></td>
    </tr>
    <?php endforeach; ?>
  </table>

Any thoughts?
Neil

p.s. I emailed you yesterday but not sure if you got it?

Submitted by support on Thu, 2008-09-11 10:38

Hi Neil,

I think I spotted the problem looking at your email - i've sent you an alternative version to try.

Cheers,
David.

Submitted by npaitken on Thu, 2008-09-11 15:19

Hi Dave,

You're right...as always. Leaving (.txt) extention off the filename solves my problem.

Many thanks,
Neil

Submitted by Misalf on Tue, 2011-05-17 14:51

Sorry to open an old post, that is so important and useful modification.
I have been trying to use this mod, managed to do it this way (ending descriptions files by .php)

<?php
  if (file_exists("descriptions/".$mainProduct["name"].php))
   {
     require("descriptions/".$mainProduct["name"].php);
   }
   else
   {
     print $mainProduct["description"];
   }
?>

In case of using .txt file, I am not able to get it working, as with npaitken user. I remove .txt extension from descriptions files, still not working: My question is: how do you name descriptions files in order to work with the original David code mod (without .php extension):

<?php
  if (file_exists("descriptions/".$mainProduct["name"]))
   {
     require("descriptions/".$mainProduct["name"]);
   }
   else
   {
     print $mainProduct["description"];
   }
?>

Thanks

Submitted by support on Tue, 2011-05-17 14:56

Hi misalf,

Make sure to use quotes around the extension, e.g.

<?php
   
if (file_exists("descriptions/".$mainProduct["name"].".txt"))
   {
     require(
"descriptions/".$mainProduct["name"].".txt");
   }
   else
   {
     print 
$mainProduct["description"];
   }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by Misalf on Tue, 2011-05-17 16:54

Thanks so much David!

That is a great mod.

Greetings

Submitted by Dale on Tue, 2015-07-07 02:22

Hi David

Could you tell me how I go about setting this up when using PT with Joomla?

Many thanks
Dale

Submitted by support on Tue, 2015-07-07 08:23

Hello Dale,

Sure - exactly as described above set-up the descriptions/ folder as a sub-directory of the Price Tapestry installation folder, containing Product Name.txt files where Product Name exactly matches the product name as it appears on your site.

With that in place, edit the plugin file plugins/system/plg_pto_system/pto_product.php and look for the following code at line 392:

    if ($product->description)

...and REPLACE with:

   global $pto_config_externalPath;
   $filename = $pto_config_externalPath."descriptions/".$product->name.".txt";
   if (file_exists($filename))
   {
     $product->description = file_get_contents($filename);
   }
   if ($product->description)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Dale on Tue, 2015-07-07 14:43

Many thanks David. I'm getting an 'unexpected if' parsing error when I add the code though. Maybe a typo or something?

Also, is this the same kind of procedure I'll need to use for the search results?

Regards
Dale

Submitted by support on Tue, 2015-07-07 14:51

Sorry Dale, there was a missing ";" on line 2 of the replacement - corrected above.

Regarding search results, almost identical replacement, this time in the plugin file plugins/system/plg_pto_system/pto_search.php look for the following code at line 514:

   if ($row->description)

...and REPLACE with:

   global $pto_config_externalPath;
   $filename = $pto_config_externalPath."descriptions/".$row->name.".txt";
   if (file_exists($filename))
   {
     $row->description = file_get_contents($filename);
   }
   if ($row->description)

Cheers,
David.
--
PriceTapestry.com

Submitted by Dale on Tue, 2015-07-07 15:00

Works great now, many thanks David!