Forums / Customization from the Admin / Problems validating my HTML with ampersands in define pages

Problems validating my HTML with ampersands in define pages

Locked

Views: 4,217

Results 1 to 19 of 19
This thread is locked. New replies are disabled.
11 Jun 2008, 04:46
#1
paulspiller avatar

paulspiller

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Problems validating my HTML with ampersands in define pages

Hi I am attempting to add some HTML in the main page PHP data area. It works fine but with the following elusive problem.

I am adding links containing for example: href="http://localhost/~xxxxx/zencart/index.php?page_2=index&cPath=3_10"> to the area. To be verifiable HTML after downloading, the "&" must be changed to "&".

On my localhost test installation (Imac) it works fine, allows me to edit and save the change. The downloaded HTML reflects the change and all is well.

However, On a real server site, I can edit the change but after saving, the change disappears - that is it is removed by the save - other changes are fine like the new path up to the "/index......". The downloaded HTML verifies that the change was not made.

Is this a character set problem or configuration setting with PHP or MySql or a Zencart setting. What character set should I be using? The SQL connection char set for the server is "utf8_unicode_ci". My localhost shows encoding as "ISO Latin 1". I dont fully understand the relationship here and in particular can I change these without losing data as a trial and error exercise. This is a grey area for me and would appreciate any pointers.

It seems that the "&" is acting as some sort of escape character but why only on a remote server ??

Everthing else seems to be working fine. Actually, except for the HTML verify, the change does not seem to be necessary anyway - it performs as expected either way ??

Regards Paul :huh:

11 Jun 2008, 05:21
#2
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Hi Paul, welcome to the Forum. :smile:

Without getting into the coding pro's & con's of what you mentioned, your problem is not as difficult as it may sound. You will find that you can use the ASCII & as a replacement and it will correctly show within the page output of your Zen Cart store. However, if you go back to make a change the ASCII is gone and it's a regular & again.

You should be able to confirm this by testing within your site.

You know, it just dawned on me that you were referring to manually inputted URLs with an & and my statement above is referring to changes within the Categories/Products section of the Admin. I haven't tried using ASCII as you described but shall keep my post as is because it may or may not work for you but will definitely help someone in the future, if they are using the Categories/Products section.

11 Jun 2008, 12:28
#3
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

I can confirm that what you describe is normal within ZC, when using the define pages editor. It's an irritant, but now that you know, you'll just have to remember to type & instead of & whenever you need one in a URL.

Rob

12 Jun 2008, 00:24
#4
paulspiller avatar

paulspiller

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Thanks for the replies folks.

If it normal with ZC as Rob points out, I still have a problem or maybe the problem is with what I am trying to do. :cry:

The actual problem is that I cant put the "amp;" in define pages. The html I am adding in the main page data includes links to what is normally a menu item link. The only way I found to do this is look at what the normal zencart menus did in the downloaded html and copied that bit if info that includes the "..../index.php?page_2=index&cPath=3_10". This works fine but has the html verification problem.

One main question is why does it allow me to add the "amp;" when using a localhost but not on a network server ?? It can only be some configuration setting "surely".

The other thing is that perhaps I am tackling the whole thing wrong and should not be adding this info. However I dont know any other way to add this bit of info to point to the database data I want (a category). Maybe adding menu items as html modifications as I am attempting (for a third party) should not be done - out of the scope for modifications perhaps ?? I do personally believe we should use the facilities provided as much as possible and leave well alone but this is what the "third party" requested. :frusty:

If it is stepping out of the bounds of what we can and cannot modify, please tell me and I will look at other options.

The (test and dev) url for anyone interested is https://www.simply-web.info/demo2/zencart

The items in question are the icons in the white background on the right.

Regards. Paul

12 Jun 2008, 12:27
#5
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

With an actual URL to go by and from checking things out, seems everything is working as it should.

https://www.simply-web.info/demo2/zencart The items in question are the icons in the white background on the right.

Of the 3 icons on the right, one of the URLs use an ASCII ampersand and two do not. The two that do not are what's being picked up as incorrect.

index.php?page_2=index&cPath=3_10" index.php?page_2=index&cPath=3_13" index.php?page_2=index&cPath=3_12"

Change the second two to include an ASCII ampersand as well.

12 Jun 2008, 12:48
#6
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

I got you off on a wrong tangent there. I was thinking you were using the define pages editor, but it sounds more like you're doing your edits in the php files themselves. That's a different kettle of fish, to change metaphors in mid-stream. :smartalec:

Rob

14 Jun 2008, 03:20
#7
paulspiller avatar

paulspiller

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Rob and others.

Ok I have an answer to both my problem and a pointer to what is happening I think. Firstly, being new to this I thought the MySql database was involved - it seems it is not - the php file is being updated. (It is now more logical as that is what the "define page editor" implies).

I found that (even in a localhost) that using "define page editor" to add "amp;" after the "&", in "define_main_page_php" I could add it but the very next time the editor accessed the php file to change anything, the "amp;" was removed by the editor it seems. In a remote server the process varies a bit - I dont fully understand why.

What I have now done is edit the "define_main_page.php" file directly using my trusty text editor. I can now add what I like and it remains. All seems fine now. :clap: What I am trying to do with the code may be questionable but that is another issue.

In summary it seems that this particular problem lays with the "define page editor" itself. A small problem but a problem no less. If the 'define page editor" does what it likes there is an obvious problem. :blink:

Thanks all Paul

14 Jun 2008, 19:23
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
174

Re: Problems validating my HTML with ampersands in define pages

With respect to define-pages, Zen Cart doesn't alter the submitted code other than to sanitize slashes. Thus, the changing of ampersands must be occurring via the use of one of the rich-text editing tools ... You're free to try different rich-text editors if you wish to try out different approaches available. Or, you can create your own raw HTML by turning off the rich-text ("HTML Editors") editor and just using "Plain Text" mode.

14 Jun 2008, 20:06
#9
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

DrByte, if you refer to post #2 of this thread and do a test, you will see the same thing happen in the Admin > Category/Products section; especially when naming is used.

14 Jun 2008, 20:37
#10
kim avatar

kim

Obaa-san

Join Date:
Jun 2003
Posts:
26,564
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Why not alter and use the built-in "Always show main categories on home page" facilities that Zen has?

15 Jun 2008, 13:31
#11
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

DrByte:

With respect to define-pages, Zen Cart doesn't alter the submitted code other than to sanitize slashes. Thus, the changing of ampersands must be occurring via the use of one of the rich-text editing tools ... You're free to try different rich-text editors if you wish to try out different approaches available. Or, you can create your own raw HTML by turning off the rich-text ("HTML Editors") editor and just using "Plain Text" mode.

I hesitate to debate this with one of the Zen masters, but my experience is not quite what you describe. But perhaps this is a "Who's on first" kind of discussion. In any case, I will plunge on...

Selecting the Define Pages Editor, and with Text Editor set to Plain text, if I enter & inside a URL and then save the file, when I reopen that file for further editing, the & has been changed to a simple & character. This will generate an error in the resulting rendered page if I check its syntax, so I have to remember to change the & back to & every time. (The image on the main page of both my sites is manually changed every once in a while in exactly this way.)

But I guess we're well off topic now. Just thought I'd clarify what I was saying above.

Rob

15 Jun 2008, 13:37
#12
kim avatar

kim

Obaa-san

Join Date:
Jun 2003
Posts:
26,564
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

No debate necessary. We are aware of the problem special characters being "cleaned" too well when going back and forth from the editor to the database and it is being worked on for the next release.

18 Jun 2008, 12:02
#13
paulspiller avatar

paulspiller

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Hi all Kim, I wanted to use the "standard" facilities of zencart but the client wanted linked icons for the front page. Maybe there is another way but I couldnt get the results I wanted. (Thats me anyway). The client did not like the "standard" outcome. But as I say more research and I am sure there would be a better way. My time and brief was finite - I was doing html and css mods only - the layout was dictated. I did learn a valuable lesson.

I dont like fiddles with products and this is an example of the problems that can arise.

But even though I can fix the prob, I still dont understand why it works in localhost mode ?? Surely it must be a config setting somewhere. Kim mentioned the database but it seems that just a file is being updated (or is that still part of the conceptual database).

Its good to see it is being addressed.

Lets close it off - Thanks for the help all. :clap:

Paul

(I just realised I dont know how to "close it off" - can someone do it please - if indeed there is such a concept). :wacko:

19 Jun 2008, 11:06
#14
paulspiller avatar

paulspiller

New Zenner

Join Date:
Jun 2008
Posts:
6
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

sorry folks

I stated that it does work in localhost mode where it actually does not.

I have another problem with Safari and crossed my wires there.

Maybe it was the two or five wines I had a short time ago.

Paul

20 Aug 2008, 09:08
#15
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Kim:

No debate necessary. We are aware of the problem special characters being "cleaned" too well when going back and forth from the editor to the database and it is being worked on for the next release.

I find that I can't use Ampersand in category listings on zen cart, or they are simply "cleaned".

I need a lot of ampersands, because in many places I'm using links, and as you know, I need ampersands to write XHTML valid links.

my html must be=> /index.php?main_page=index&cPath=65 to create => /index.php?main_page=index&cPath=65 & keep it xhtml valid

ANyway, I see you guys are already aware of the issue--

I went directly into the database to fix my pages--but now I can't simply edit them.. I'm forced to do tedious database work..

Is there a way to hack categories.php so it will stop messing with my "&" ampersands?

20 Aug 2008, 19:44
#16
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

dontknowwhatimdoing:

I find that I can't use Ampersand in category listings on zen cart, or they are simply "cleaned".

I need a lot of ampersands, because in many places I'm using links, and as you know, I need ampersands to write XHTML valid links.

my html must be=> /index.php?main_page=index&cPath=65 to create => /index.php?main_page=index&cPath=65 & keep it xhtml valid

ANyway, I see you guys are already aware of the issue--

I went directly into the database to fix my pages--but now I can't simply edit them.. I'm forced to do tedious database work..

Is there a way to hack categories.php so it will stop messing with my "&" ampersands?

Well, I found the fix--from a very nice developer who decided to take pity on me. Looks like no one around here likes to play nice though (except the core development team, I love them--in a platonic way! don't get any ideas!) Go to your admin panel...

Configuration > MyStore >

HTML Editor > select: HTMLAREA

Wow.. too good to be true? Maybe.. maybe not...?

20 Aug 2008, 19:50
#17
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

dontknowwhatimdoing:

Well, I found the fix--from a very nice developer who decided to take pity on me. Looks like no one around here likes to play nice though (except the core development team, I love them--in a platonic way! don't get any ideas!) Go to your admin panel...

Configuration > MyStore >

HTML Editor > select: HTMLAREA

Wow.. too good to be true? Maybe.. maybe not...?

Hey-- looks like it's only part of the fix.. something evil in my zen cart is 'cleaning' my mysql entry before presenting it to me..

I know because I cleaned things up & made them validate to w3c standards... directly in mysql... but if I try to observe the page in my admin category listings, the "amp;" is already removed from "&"

20 Aug 2008, 20:59
#18
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

OK--none of that crap worked. But this did:

ill just find the sanitize function & comment it out.

i hope i blow up my cart.

functions_general.php line 1233 (commented out OoooOOOOo) // $string=str_replace('&', '&', $string);

rofl: (w3c validator used)

This document was successfully checked as XHTML 1.0 Transitional!

I probably broke something else.. but hey, my pages are valid now yay...

27 Aug 2008, 13:05
#19
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: Problems validating my HTML with ampersands in define pages

Thanks for posting that! The ampersand thing has been bothering me for ages, as I manually update the image on my home pages every once in a while.

Rob