DrByte:
Sorry. It's really nothing personal. I've been battling a really challenging project today, and taking personal attacks from a crew of jerks. I'm terribly sorry it's spilled off on you. I'm "escaping" the madness by answering forum posts.
Thanks for voicing it. I'm not proud of treating you like that.
Apology accepted, I get exactly the same with clients who also attack me. In all honesty I get days where I want to throw my machine through the window, so I do understand. I do already understand a vast amount about Zen Cart as a developer/designer compared to most, but there are situations like this where I need help to get me through, which is why I ask questions on the forum. If I can, then I will find a way without having to ask. However sometimes, I have no choice but to ask as it is sometimes quicker to see if someone else has come up against the issues to hand on here. While I am a developer/designer, I don't know everything and don't claim to. Good, clean communication always helps to get onto the matter to hand, and for a better relationship though! And the reason I mentioned 'everytime' is because I have had other situations where you have answered in ways which have a 'feel' to them that come across as probably not really wanting to answer or could be interpreted as 'your a developer, you should know this stuff'. As I said earlier though, I don't know everything and don't claim to know everything. Right, rant over, can we be friends now and keep it that way? and also get onto the matter to hand?
DrByte:
We've gone around in circles because I assumed you wanted to clean the database, cuz that's the most common kind of request I see. But, now that I think we're seeing it the same way, I have some ideas:
It might seem silly not to clean the database and I appreciate that some people don't have Javascript enabled. However the website I am working on is most likely going to be viewed by people who do have javascript enabled and I'd like to think that as Zen Cart already utilises Javascript and Jquery, I could use it without too much hassle. I'm already aware that using Javascript or Jquery or even PHP to serve the data as it is, but to the viewer in a cleaner form, which to them looks no different to the rest of the site, may not be the correct method. And the proper method would be to meticulously clean the database. However, I have alot of jobs to do that have a higher importance, and to sit and do that would take up vast amounts of time. Also I am not being paid to clean up the DB code in such a way. So I suppose yes, I am looking for a fudge or workaround. It isn't ideal, but if it saves time and does the job without causing too many issues then it is quicker solution. Maybe not correct, but if it does the job, it does the job!
DrByte:
I haven't set up a site to test your exact situation. But this is how I'd tackle it (although I'd prefer to clean the database instead):
I'm gonna assume that the javascript you quoted for doing the cleaning is trustworthy and properly functional to do the task required.
In all honesty, its a third party script which I found through google posted from others with similar issues on other websites such as wordpress based websites. So I haven't properly tested it, but then I couldn't get them to run and I couldn't see if it was something I was missing that I needed to change. So I suppose its a stab in the dark really.
DrByte:
a) get the javascript for the cleanup function into the page. This can be done several ways. Two common ways are to either paste it into the HTML of the template file, such as tpl_product_info_display.php (above where the description is output), or to put it in a jscript_xxxxx file as described in the article I linked to (so that it loads in the head of the page).
b) then, somewhere on the page, at a point after the cleanup function is loaded into the page's HTML, add some javascript to "fire" the cleanup. I'd probably put that in the tpl_product_info_display.php after the output of the product description field.
Perhaps this sort of code might work:```
<script type="text/javascript">
// get all elements using this class name
var x = document.getElementsByClassName("mainDescription");
var i;
// loop thru all the found elements, and replace them with the cleaned version
for (i = 0; i < x.length; i++) {
x[i].innerHTML = cleanHTML(x[i].innerHTML);
}
</script>
I already tried loading this into the head, but then I probably didn't fire it properly. So I will give that a try first before I come back to this. So now we are friends, if I need your help on this can I come back to you please?