Hi David,
is it possible to create a JavaScript for entering in the "text after" filter, e.g. a random text js., or is there only text possible?
Regards
Roland
this is my randomtext.js
var num_quotes = 5
var quotes = new Array(num_quotes)
quotes[0] = "?"
quotes[1] = "?"
quotes[2] = "?"
quotes[3] = "pan?"
quotes[4] = "?"
var n = Math.floor(Math.random() * num_quotes)
document.write( quotes[n] )
and I entered the tag as you mentioned, but I get an error.
Regards
Roland
Regards
Hi Roland,
The code appears to missing semi-colons as required by JavaScript syntax, I just tested using:
var num_quotes = 5;
var quotes = new Array(num_quotes);
quotes[0] = "aaa";
quotes[1] = "bbb";
quotes[2] = "ccc";
quotes[3] = "ddd";
quotes[4] = "eee";
var n = Math.floor(Math.random() * num_quotes);
document.write( quotes[n] );
...but also the <script> tag may also need to be close explicitly, so in your filter, try:
<script type='text/JavaScript' src='/randomtext.js'></script>
Cheers,
David.
--
PriceTapestry.com
It works perfect. Would it also work with filter " Text before" in field description?
Regards
Roland
Hello Roland,
Yes - it will work exactly the same in Text Before.
Cheers,
David.
--
PriceTapestry.com
Hi David,
I do not know how this can happen:
I have two Websites:
{link saved}
The installation of the filter and of randomtext.js is exactly the same, but the result is different. Whereas the site {link saved} works without any problem and shows the text before in the right way, in the other website only the code <script type='text/JavaScript' src='/randomtext.js' > </script>
appears. How can this happen?
Regards
Roland
Hi Roland,
On your site where the code is being displayed literally in the output, check your html/product.php and see whether the code that prints out $mainProduct["description"] uses html_entities() as that would cause this to happen, e.g.
print htmlentities($mainProduct["description"],ENT_QUOTES,$config_charset);
...if that's the case, REPLACE with just:
print $mainProduct["description"];
...and that should be all it is....
Cheers,
David.
--
PriceTapestry.com
Hi David,
was some days with my sons....Niow I tried what you propose, but ist still does not Change.
My html/product.php Looks like this:
<div class='product'>
<?php $mainProduct = $product["products"][0]; ?>
<table width='100%'>
<tr>
<td width='200'>
<?php if ($mainProduct["image_url"]): ?>
<img width='180' src='<?php print $mainProduct["image_url"]; ?>' alt='print $mainProduct["description"];' />
<?php endif; ?>
</td>
<td valign='top'>
<h3><font color="red"><a href='<?php print tapestry_buyURL($mainProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a></h3>
<?php if ($mainProduct["description"]): ?>
<p><?php print $mainProduct["description"]; ?></p>
<?php endif; ?>
<table border='0' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' style='padding:0px;margin:0px;'>
<?php if (count($product["products"]) > 1): ?>
<strong><?php print translate("Best Price"); ?>:</strong>
<?php else: ?>
<strong><?php print translate("Price"); ?>:</strong>
<?php endif; ?>
<?php print $config_currencyHTML.$mainProduct["price"]; ?> <?php print translate("from"); ?>
</td>
<td valign='top' style='padding:0px;margin:0px;'>
<?php foreach($product["products"] as $priceProduct): ?>
<?php if ($priceProduct["price"] == $mainProduct["price"]): ?>
<a href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?>><strong><?php print $priceProduct["merchant"]; ?></strong></a>
<?php if ($priceProduct["voucher_code"]) print " ".translate("using voucher code")." <strong>".$priceProduct["voucher_code"]."</strong>"; ?>
<br />
<?php else: ?>
<?php break; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if (isset($mainProduct["extraHTML"])) print $mainProduct["extraHTML"]; ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
Regards
Roland
Hi Roland,
Could you let me know an example product page URL where the filter doesn't appear to be working and
only showing the output directly on the page rather than running the JavaScript and I'll take a
look at the source for you...
(I'll remove your URL before posting your reply)
Thanks,
David.
--
PriceTapestry.com
Hi David,
please go to www.brand-fashion.com and click on a product. The Output for the product-page is correct, but the similar products do Show the fault.
Regards
Roland
Hi David,
I found the fault. It was in searchresults.php
.......substr($product["description"],10,250); ?>
I changed it to
($product["description"]);
and now it works. Or do you have a better solution?
Regards
Roland
Spot on, Roland - although no need for the brackets once substr() has been removed but that doesn't really matter..!
Cheers,
David.
--
PriceTapestry.com
Hello Roland,
No reason why the text entered into a Text After filter can't contain JavaScript, but I would only recommend doing this with something like the Description field which is only used for output - I would _not_ use it with things like product name, category etc.
To add a script tag to the end of the description it would be simply;
<script type='text/JavaScript' src='/randomtext.js' />
(assuming randomtext.js in home directory - src attribute must be absolute so that the browser can locate the script from virtual sub-directories e.g. /product/Product-Name.html)
Cheers,
David.
--
PriceTapestry.com