Results 1 to 10 of 28

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Strip HTML and WORD formatting

    The scripts already exist. I'm not after a script to rewrite/clean the entire database. I can most likely override spans with CSS, that is fine and I am aware of how that can be done.

    The scripts I posted earlier on in this conversation are third party scripts which are supposed to seek out certain html/word elements and disable them, however they are supposed to keep everything in between those elements. However I could not get these to work with Zen Cart. They do not rewrite the content, just strip away/disable certain tags.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Strip HTML and WORD formatting

    Okay. So you've got some scripts. The stuff you posted earlier is javascript.

    You said you don't want to clean the entire database.

    But you said you don't want to edit each product manually.
    So that means you *do* want to clean all of them in some automated way.

    But javascript code such as you've posted is designed to run in the browser. And the browser has no access to the database.
    So you need a script to pull each record from the database individually, put it in your browser, and then perform some sort of cleaning on the data, and then send the data back to your store's admin to save the changes back to the database.

    Am I correct that you're asking one of us to provide all of that for you?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Strip HTML and WORD formatting

    Quote Originally Posted by DrByte View Post
    Okay. So you've got some scripts. The stuff you posted earlier is javascript.
    That is correct.

    Quote Originally Posted by DrByte View Post
    You said you don't want to clean the entire database.
    Correct

    Quote Originally Posted by DrByte View Post
    But you said you don't want to edit each product manually.
    So that means you *do* want to clean all of them in some automated way.
    Correct

    Quote Originally Posted by DrByte View Post
    But javascript code such as you've posted is designed to run in the browser. And the browser has no access to the database.
    Correct

    Quote Originally Posted by DrByte View Post
    So you need a script to pull each record from the database individually, put it in your browser, and then perform some sort of cleaning on the data, and then send the data back to your store's admin to save the changes back to the database.
    Not correct

    Quote Originally Posted by DrByte View Post
    Am I correct that you're asking one of us to provide all of that for you?
    No I am not asking you to provide that as obviously I would be asking you to clean the entire database and I'm sure you would be submitting an invoice as a result.

    I think your missing the point.

    I'm not asking for a script to pull each record from the database individually, put it in your browser, and then perform some sort of cleaning on the data, and then send the data back to your store's admin to save the changes back to the database.

    The scripts I posted are browser side only, they will not save back to the database, I'm aware of that and I do not want them to.

    However, these scripts are supposed to recognise word formatting styles, disable them and leave everything in between so what appears in the browser to the end user (the viewer) is cleaner text/content that doesn't appear to have word formatting and is overridden with a mixture of a script and CSS. Even though in fact if you looked at the source code, the word formatting styles would still be in the code.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  4. #4
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Strip HTML and WORD formatting

    Oh, so you don't want clean data in your database. You want to fudge the output to the browser, so that every time a customer visits your site the data is re-cleaned in front of them, while they wait for the page to display.

    Sorry, I've never heard anybody say they want to leave the mess in their system and bandage it every time the customer consumes it, over and over again.

    But, ya, you can do that if you like.

    To add any javascript into your site, simply put the javascript in an appropriately-named file, and add an event (onload perhaps) to fire it. Most of that is outlined here: https://www.zen-cart.com/wiki/index....s_-_Javascript
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Strip HTML and WORD formatting

    Why the sarcasm? I seem to get this everytime in some form, from you for some reason Dr Byte. It would be nice to get straightforward answers though. I appreciate your higher authority but it just feels like sometimes your having a go at me for asking a question? I wouldn't be asking if I knew the answer.

    And really you haven't answered the original question anyway anyway as you have just told me to do what I have tried already.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  6. #6
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Strip HTML and WORD formatting

    Quote Originally Posted by Nick1973 View Post
    Why the sarcasm? I seem to get this everytime in some form, from you for some reason Dr Byte.
    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.

    Quote Originally Posted by Nick1973 View Post
    And really you haven't answered the original question anyway anyway as you have just told me to do what I have tried already.
    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:

    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.

    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:
    Code:
    <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>
    Last edited by DrByte; 15 Apr 2016 at 08:15 PM. Reason: added the comments to the javascript
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Strip HTML and WORD formatting

    Quote Originally Posted by DrByte View Post
    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?

    Quote Originally Posted by DrByte View Post
    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!

    Quote Originally Posted by DrByte View Post
    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.

    Quote Originally Posted by DrByte View Post
    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:
    Code:
    <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?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  8. #8
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Strip HTML and WORD formatting

    Quote Originally Posted by Nick1973 View Post
    Why the sarcasm? I seem to get this everytime in some form, from you for some reason Dr Byte. It would be nice to get straightforward answers though. I appreciate your higher authority but it just feels like sometimes your having a go at me for asking a question? I wouldn't be asking if I knew the answer.

    And really you haven't answered the original question anyway anyway as you have just told me to do what I have tried already.
    Can't speak for other things, but the bolded information wasn't known until this final post. Another thing is that if the source data truly remains unfixed, then those that have disabled or can't run javascript will be subject to the "Word" data regardless, also in this era of pay by data, all of that extra data will be fed to the visitor only to be reduced locally, so becomes unnecessary information. It would almost be better to put such a script on the admin side (for future use) that would essentially prevent adding all of that, or to in some way enable a feature of ckeditor to not allow such content to be added (again more of a future proofing than a correct the present situation.)

    Otherwise, and haven't actually looked at the detail of the located script, but if equivalent php could be identified, EP4 (discussed briefly in a thread by the OP) could be piggy backed upon to strip the errant information while exporting the data and then the resulting file reuploaded. (There are notifiers in the export that could support such data modification.)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Strip HTML and WORD formatting

    Quote Originally Posted by mc12345678 View Post
    Can't speak for other things, but the bolded information wasn't known until this final post.
    I think I probably mentioned it, but probably wasn't clear. That is my fault so sorry if it wasn't clear.

    Quote Originally Posted by mc12345678 View Post
    Another thing is that if the source data truly remains unfixed, then those that have disabled or can't run javascript will be subject to the "Word" data regardless, also in this era of pay by data, all of that extra data will be fed to the visitor only to be reduced locally, so becomes unnecessary information.
    Appreciate that, however we are talking about people who view websites in standard browsers and who wouldn't have a clue how to turn off javascript. This is a shop selling tradesmens products and they wouldn't know what javascript is so I don't see it as a problem. Also Javascript is used in Zen Cart to run other elements in the Zen Cart scripts. So if the data is a problem with word formatting, then it is probably also a problem elsewhere too.

    Quote Originally Posted by mc12345678 View Post
    It would almost be better to put such a script on the admin side (for future use) that would essentially prevent adding all of that, or to in some way enable a feature of ckeditor to not allow such content to be added (again more of a future proofing than a correct the present situation.)
    I agree, some sort of button to clean up the data in one sweep would be very useful.

    Quote Originally Posted by mc12345678 View Post
    Otherwise, and haven't actually looked at the detail of the located script, but if equivalent php could be identified, EP4 (discussed briefly in a thread by the OP) could be piggy backed upon to strip the errant information while exporting the data and then the resulting file reuploaded. (There are notifiers in the export that could support such data modification.)
    Not entirely sure what you mean, but I think probably your talking about a cleaner exported version of the data that could be imported back into the DB.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

 

 

Similar Threads

  1. Word HEADER_ bin the menu bar and after the word login
    By moro in forum Installing on a Windows Server
    Replies: 1
    Last Post: 18 Dec 2011, 03:14 PM
  2. html email formatting
    By ads112001 in forum General Questions
    Replies: 1
    Last Post: 23 Feb 2011, 07:15 PM
  3. SEO URLs - how to strip HTML tags from product names?
    By gregy1403 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 14 Sep 2010, 04:31 PM
  4. Product listing - Don't strip html!
    By Jazzperson in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 6 Nov 2007, 04:31 PM
  5. WYSIWYG downloads? Problem with ms word html and the HTMLarea
    By vandiermen in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 11 Sep 2007, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg