DylzEn Posted August 3, 2013 Share Posted August 3, 2013 Hello guys. I'd like to know if there is any way to use insert a line break in the category name. I'd lke to use it because in the category tree of the blockcategories module I have some long name categories, and when there's no more room for a word it just goes into a new line in a wrong way. I'd like to decide when to go for a new line. I hope I explained myself. After some searches in the forums, I went and edited the file "classes/Validate.php" removing the characters "<" and ">" from the return statement of the isCatalogName() function, so it now looks like this: public static function isCatalogName($name) { return preg_match('/^[^;=#{}]*$/u', $name); } This allows me to not get an error when I insert the the tag <br> in the category name from the BO. It says update succesful but nothing really changes and the name stays like it was originally. Any help would be appreciated. Thank you guys. Link to comment Share on other sites More sharing options...
PascalVG Posted August 3, 2013 Share Posted August 3, 2013 After playing and playing, the only working 'solution' I can create is forget about inserting the html tags, but use a (This is a NON-BREAKABLE space) instead of a normal space between words you would like to keep together You need to change the isCatalogName a little. Restore the original '<' and '>' but delete the ';' Then you can add the string code between the words where needed For example If you have a string like this: This is a very long string that splits incorrectly and it hapens to split like this: This is a very long string that splits incorrectly but you actually want it like this: This is a very long string that splits incorrectly Make your input string like this: This is a very long string that splits incorrectly Only 'problem' I bumped into was that the long category name may get toooo long (i.e. more than 64 chars reserved for the name) A quick check seemed to render the text normally at other places in Prestashop (i.e. no stange code, but a neat (unbreakable) stpace, but please double check! I hope this may work for you. pascal Link to comment Share on other sites More sharing options...
DylzEn Posted August 3, 2013 Author Share Posted August 3, 2013 (edited) First of all, thanks for your time and effort, PascalVG. Now, I like your solution and I surely didn't think about using the entity before. The thing is, Prestashop is acting weird as usual after I add the to the category name. That is, it looks like it works perfectly in the back office but not in the front office: I pick a category from my site, for example CAMEROUN (C.A.S.) (U) and since I don't want it to split like CAMEROUN (C.A.S.) (U) I edit the name like you told and make it CAMEROUN (C.A.S.) (U) Now, I save and return to parent category. In the category list there, the thing splits correctly like it is meant to. When I go to my fron t office though, it's like the site won't recognize the like an entity so it just displays the whole text, like this: CAMEROUN (C.A.S.) (U) Here's my site if you want to check it out: www.tangrediworldbanknotes.com/en/ I edited a few categories like that. I also deleted the content of the /smarty/cache and /smarty/compile folders, but it didn't help. Do you have any idea why this is happening? Thanks again for your time, I really appreciate it. Dylan Edited August 3, 2013 by DylzEn (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 3, 2013 Share Posted August 3, 2013 Hi Dylan, Hmmm, strange indeed. Stranger even, I see for World bank notes->Africa a Benin (W.A.S.) (U) as with a normal space on my Mac->Chrome On my iPad however, I see Benin (W.A.S.) (U) Needs some more research... Will be tomorrow, though. It's 2 AM here... pascal Link to comment Share on other sites More sharing options...
DylzEn Posted August 3, 2013 Author Share Posted August 3, 2013 (edited) Stranger even, I see for World bank notes->Africa a Benin (W.A.S.) (U) as with a normal space on my Mac->Chrome On my iPad however, I see Benin (W.A.S.) (U) If you checked on your iPad first, that might be because I had the in there and after a few minutes I changed it back to a nromal space because I don't really need it there, maybe that's why you saw a normal space on your Mac. Anyway, I'm gonna look into it a bit more and let you know if I come up with something. Thanks again. EDIT: I solved it by removing all the escape modifiers from the category-branch-tree.tpl and delete the content of those two smarty subfolders again. The entities still show in the breadcrumb though, so I need to figure out how to solve this issue now. Dylan Edited August 3, 2013 by DylzEn (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 5, 2013 Share Posted August 5, 2013 Hi Dylan, Did you just take away the breadcrumb (for now?) to 'solve' this problem? Can't find it on your site. See that the nbsp's are working in your cat.list. Good! Let me know if you still want me to help finding a solution for the breadcrumbs pascal Link to comment Share on other sites More sharing options...
DylzEn Posted August 5, 2013 Author Share Posted August 5, 2013 Hi. Yes, I took it away because I haven't found a solution yet and the breadcrumb like that is just messed up, as you can see in the screenshot I'm attaching. Can't figure out how to prevent the breadcrumb from escaping the html code. Any idea? Thanks for your concern anyway. Dylan Link to comment Share on other sites More sharing options...
PascalVG Posted August 5, 2013 Share Posted August 5, 2013 (edited) What does work is to put function html_entity_decode () around the $path in breadcrumb.tpl So do this. Edit themes/<your theme folder>/breadcrumb.tpl. Somewhere in the beginning of the file you see this line. Add the red line just underneath it: {if isset($path) AND $path} {assign var = path value=html_entity_decode($path) } That should do it, pascal Edited August 5, 2013 by PascalVG added path to breadcrumb (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 5, 2013 Share Posted August 5, 2013 This might work for your first edit you did before as well, (i.e. instead of removing the escape modifiers) ) pascal Link to comment Share on other sites More sharing options...
DylzEn Posted August 5, 2013 Author Share Posted August 5, 2013 Alright, there were two missing " ' " around "path" in your line so it gave me a syntax error. The correct code should be: {assign var='path' value=html_entity_decode($path)} That being said, that works at 99%, becuase the entities are gone but now the characters with an accent are not recognized and show a question mark, like in this screenshot: So it's basically a decoding issue. Therefore, I used the parameters to explicit convert the path string to UTF-8, because the default conversion seems to be to Standard ISO, like this: {assign var='path' value=html_entity_decode($path, ENT_COMPAT, 'UTF-8')} and now Prestashop wants to give me this error: Why does it say it expects a long parameter now? The html_entity_decode is defined like this: string html_entity_decode ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' ]] ) From the official PHP manual. Bah, I'm thinking about losing the breadcrumb and just show the category title on top. Thanks again for your time, Pascal. Link to comment Share on other sites More sharing options...
PascalVG Posted August 5, 2013 Share Posted August 5, 2013 (edited) Hmmm, no idea. You can try to convert these special chars also to their html entities: http://www.web2gener...m/html/entities for example, instead of the é, add é Cumbersome work though... The page above may help a little with the translation, but still... Still searching. If no idea, we can try and open a new topic about it... Sorry to be of little help here... pascal EDIT: Looks like there are only about 5 categories with the é, so maybe this will 'work' after all) Edited August 5, 2013 by PascalVG : added an EDIT note (see edit history) Link to comment Share on other sites More sharing options...
DylzEn Posted August 5, 2013 Author Share Posted August 5, 2013 (edited) You can try to convert these special chars also to their html entities: http://www.web2gener...m/html/entities for example, instead of the é, add é If I do that, all the breadcrumb text disappears, except from "Home". Too many headaches. I got rid of the breadcrumb. Thanks anyway. Can I go on and mark this topic as solved since the original issue was indeed solved? Thanks for your help, I really appreciated it. Dylan Edited August 5, 2013 by DylzEn (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now