Encoding entities, urls and php

Hi all,

I’ve been busily adding items to a css menu using the “PHP Text Link With Query” Action, and all has worked well until I came across a slight problem with an entity encoded degree sign (°) which is made up of an ampersand followed by “deg;”. When it is used as part of a description that is passed to a mark-up item via the database all is well but if the ampersand is encountered as part of a url that is used to select an item from the database it is interpreted as %B0 so 90° (90 ampersand d e g semicolon) becomes 90%B0 (90 percentsign B 0) so it breaks the inerpretation in the link.

I have partially solved that problem using %26 instead of the ampersand in the links in the url. This works until you click on a “buy” link which takes you to the Mals-e.com site. Encoded in this link is a return link which is made up of the url of page the buy link was on plus the php used to select the products from the database which is made up “on the fly” by the server, returning you to page you came from. The problem is that the ampersand is getting changed to %B0 and is again breaking the return link. When you click on “Continue Shopping” to go back to the page you came from the page comes up but without any products on there.

It is one of those small problems that I need to solve, The degree sign shows up on all the product pages, but the url encoding problem has got me a bit stumped.

here’s a link to the development version of the site -

http://www.cotswoldengineeringsupplies.co.uk/2009-dev/Adaptors/adaptors.php?item=90%26deg;%20Elbow%20Adaptors&inthere=&line=Hydraulic%20Adaptors

The menu to use is on the right hand side - click on HYDRAULIC ADAPTOTRS > Elbow Adaptors > 90° then select your item by clicking on the “Buy” link, then click on the “Continue Shopping” link to return you to the page you came from. The link back will work on all links except the one with the entity encoded ampersand.

The other thing I could do is not have the degree sign in any of the links but to substitute deg instead, but with the degree sign I think the site looks better and it takes up less space on headings.

This is the next part of the site, the first dynamic version is up and running, just type in the url in without anything after the .co.uk bit. Just shows what you can do with Freeway!

Thanks for the help again…

Steve.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This is may not be acceptable to client, but why not use the word “degrees” instead of the symbol?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Chuckamuck,

That is something I had thought about but somehow “90° Elbow” looks better than “90 Degree Elbow” and it takes up less space.

The Degree here is an angle used in describing various engineering parts, such as elbows, cone angles etc. I think it looks more elegant to have the symbol.

It’s the return link from the shopping cart that is giving me the problem, all the other degree symbols (description etc) translate with no problem.

Steve

On 19 Feb 2009, 4:24 pm, chuckamuck wrote:

This is may not be acceptable to client, but why not use the word “degrees” instead of the symbol?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi,

I’ve just sorted this out by using the str_replace function in php.

Here’s how it works:

on the menu item in the “PHP Text Link With Query” dialogue box I have the query:

item=90 deg Elbow Adaptors

then on the search part I substitute the “deg” with “°” (ampersand d e g semicolon) for those on the web forum.

$item2 = str_replace(" deg","°","$item");

which results in the link working for the shopping cart and the nicely formatted degree sign appearing on the page. also I can leave the database as it was originally formatted.

I knew there was a way round this, just took a bit of lateral thinking – I slept on it last night, and I had an idea this morning about replacing strings (which it is), looked it up in the online php manual, did a couple of tests, and here is the answer.

It’s not often I answer my own queries!

Regards

Steve.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options