Hi david , im trying to add my own descriptions to the product page so have the below code (like the logo display code) but i want the description displayed per product not per merchant, i assume i need to change the bracketed "merchant" to "product" but its not working
i guess its something simple :)
<?php
if (file_exists("mydescription/".$product["merchant"]))
{
require("mydescription/".$product["merchant"]);
}
else
{
print " ";
}
?>
cheers david , still cant get it to display though
im using the code u posted with the .hyml extension as the file name appears in the browser
Hi Jonny,
Sorry - I just realised that if you are wanting to display this in the main product area on the products page, in place of
$product["normalised_name"]
...it would need to be:
$mainProduct["normalised_name"]
That should be all it is...
Cheers,
David.
--
PriceTapestry.com
ok last thing , i also want the new desciptions on the featured products but only showing 250 characters at the most
so the below code works but i just need to cut the decriptions down to 250 characters, not quite sure where to add it
<?php
$descriptionsFilename = "descriptions/".tapestry_hyphenate($product["normalised_name"]).".html";
if (file_exists($descriptionsFilename))
{
require($descriptionsFilename);
}
else
{
print " ";
}
?>
Hi Jonny,
Try the following - this will break your description content on the first word boundary after 250 characters (looks nicer than breaking mid-word!)
<?php
$descriptionsFilename = "descriptions/".tapestry_hyphenate($product["normalised_name"]).".html";
if (file_exists($descriptionsFilename))
{
$descriptionText = file_get_contents($descriptionsFilename);
$breakLimit = 250;
if (strlen($descriptionText) > $breakLimit)
{
$breakOffset = strpos($descriptionText," ",$breakLimit);
if ($breakOffset !== false)
{
$descriptionText = substr($descriptionText,0,$breakOffset);
}
}
print $descriptionText;
}
else
{
print " ";
}
?>
Cheers,
David.
--
PriceTapestry.com
Hi David,
I use this descriptions text to a lot. Is this possible on search keywords.
Lets say search.php?q=Searchname we get the description of Searchname?
Now i use something like this.
if (($parts[0]=="brand") && ($page==1))
Leo
Hi David,
Guess something has goes wrong with my last post, will try again.
I am bussy with navigation based on search results.
Is it possible to have own descriptions with search results?
Like you search for Diesel, search.php?q=Diesel you get description txt file for Diesel?
Thanks
Leo
Hi Leo,
Sure - within search.php you can either use the value of $q directly to load a description file, however since there can be problems with : in a filename replace it with _ before using the value of $q. Have a go with something like this:
$filename = "searchdescriptions/".str_replace(":","_",$q).".html";
if (file_exists($filename))
{
require($filename);
}
...and then make a searchdescriptions/ folder, and inside place your description files names exactly as the query plus .html, for example:
searchdescriptions/Diesel.html
searchdescriptions/brand_Nike_.html
Cheers,
David.
--
PriceTapestry.com
Hi David,
Thanks! Works perfect.
Forgat to ask that i just need something like this (($page==1))) that its showing only on the first page?
Leo
Hi Leo,
Wrap the block of code within an IF statement to restrict to page 1 - e.g.
if ($page==1)
{
$filename = "searchdescriptions/".str_replace(":","_",$q).".html";
if (file_exists($filename))
{
require($filename);
}
}
Cheers,
David.
--
PriceTapestry.com
Hi Jonny,
Wherever you have $product["merchant"] you will always have $product["name"] available so you can simply use that instead within your code.
However, it may be easier to make your description filenames use the normalised name ($product["normalsed_name"] which is the version that appears in the URL and doesn't contain any special characters that might make awkward filenames. Perhaps easier still, to determine the exact name to use, simply copy it from the URL, including even including the .html extension and then in your code, you would use:
<?php
$mydescriptionFilename = "mydescription/".tapestry_hyphenate($product["normalised_name"]).".html";
if (file_exists($mydescriptionFilename))
{
require($mydescriptionFilename);
}
else
{
print " ";
}
?>
This way, the filenames in your /mydescription/ folder simply match exactly the product URL after /product/
Hope this helps!
Cheers,
David.
--
PriceTapestry.com