You are here:  » Category content not displaying when spaces in name


Category content not displaying when spaces in name

Submitted by Birgir on Thu, 2013-06-06 17:01 in

Hi David,

I have created several categories and manually mapped the products to them. I have then updated them by re-importing the data feeds. There seems to be a problem with displaying products from categories that have spaces in between the words.

Examples:
Source location: {link saved}
Category name: CarryOnSpinner
Works ok {link saved}

Category name: {link saved}
Does not work {link saved}

Source location: same

For the purpose of testing the mapping, both categories have the exactly the same products mapped to them.

But here is the odd thing. For some categories that have more than 1 name (with spaces in between) they are displayed correctly.

Example:
Category location: Kids carry on bags
Works fine {link saved}
source file: {link saved}

I've checked the url's in the files and they are all constructed in the same way.

Any idea?

Regards,
Birgir

Submitted by support on Fri, 2013-06-07 08:39

Hello Birgir,

It's looks like the code / mod being used to generate the links isn't urlencoding the category name, that should be all it is.

For example, if you have something like this:

  print "<a href='/search.php?q=category:".$product["category"]."'>".$product["category"]."</a>";

...then to URL encode the value to make sure that spaces are correctly encoded it would be:

  print "<a href='/search.php?q=category:".urlencode($product["category"])."'>".$product["category"]."</a>";

That should be all it is (for another example look in categories.php at line 24)

Don't forget that you can also enable clean URLs by setting $config_useRewrite = TRUE; at line 8 of config.php and then creating a .htaccess file as a copy of htaccess.txt in the distribution...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com