amp and amp and... menu elements parsing

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

amp and amp and... menu elements parsing

Post by pojke » Thu Aug 18, 2011 8:36 am

A day with bugs aye?
There is somewhere a simple mistake :)

I'm mega busy so can't help you with search, but at least I'll report. Steps how to get "amp" instead of &:

- create menu with sub-elements
- create one sub-menu element with "&" char.
- in module manager add module "menu" to the website with this element, but narrow it only to submenu (start level 2 and end level 2)

Joomla will produce & in source so on the website it will be printed &.

With normal menu it works fine.

[I replaced it temporary for "and" so let me know when it'll be fixed :) ]

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Fri Aug 19, 2011 2:43 am

I am unable to replicate the error. Perhaps the & should be converted to the word and instead of the letter a. But the error you encountered did not appear.

These are the tests I performed.

Created a child item called
Test & test this
on save
The alias auto created
test-a-test-this
The menu item displayed
Test & test this

Changed the
&
to
&
Cleared the Alias
on save
The alias auto created
test-a-test-this
The Title changed to
Test & test this

Changed the
a
to
&
on save
The alias auto created
test-a-test-this

Changed the
a
to
&
on save
The alias auto created
test-a-test-this
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Fri Aug 19, 2011 3:34 am

Ok, I will show you just for one day as the website is under construction and we don't have many visitors yet :)

http://www.futurelab.co.nz/solutions/what-we-do
[the part "e-commerce & portals"]

Look on the sidebar menu and on the footer menu. The menu is exactly the same, just footer is full footer menu, sidebar is just depth 2.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Fri Aug 19, 2011 3:58 pm

I see on the bottom menu and in the Meta details on the browser
e-commerce & portals

On the side menu I see
e-commerce & portals

But using a default Template the menu in the left shows
e-commerce & portals

This suggests that the Template that you are using has a badly written Override.
Screenshot-687.png
It is often better to test with a default Template and a fresh install. That rules out other errors and premature assumptions.
You do not have the required permissions to view the files attached to this post.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Fri Aug 19, 2011 8:24 pm

Now this is really weird! I don't have any menu modifications in my template but indeed just my template makes that error.
All I have in my template html is:
com_contact
com_content
mod_articles_category

and that's it.

What I found so far is:

- In database there is just &.
- in JMenuSite::load everything looks ok and it's & as well
- now in JMenu::getItems sometimes it's & sometimes it's & when you load $this->_items array.

I have no clue what is going on between load and getItems with menu object. I definitely don't modify it, but I'm stuck with it for now...

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: amp and amp and... menu elements parsing

Post by infograf768 » Sat Aug 20, 2011 5:07 am

Maybe your template is using a "framework" and that one is messing with the menu titles.
If it is the case, contact the template developer as these "frameworks" are often the reason of various issues.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Sat Aug 20, 2011 8:17 pm

Noup, I just copied beez5 template and modified index.php and htmls - that's all.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Sat Aug 20, 2011 8:58 pm

pojke wrote:...modified index.php and htmls - that's all.
Well you modified the overrides incorrectly then. Also the beez5 Template has a lot of hard coded links in.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Sat Aug 20, 2011 11:42 pm

Now you can tell me whatever you want, but you have to admit that something is wrong ;)
I tried a lot of things, searched through the libraries, modules and... I tried to do the simplest test. Tried to turn off parts of the website and it worked.

SOoo you know where the bug is?
When you apply the same menu twice as a module. When I found it and was 99% I had to be 100% sure, so I attached a copy of footer as a module. So on one page there was 3 modules of footer menu and you know what? The first one is & , the second one is & and the third attached one is & !

Now try to blame me for that :p
Also as I mentioned, there is no modifications of mod_menu, I'm using the original one.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Sun Aug 21, 2011 1:17 am

pojke wrote:...
When you apply the same menu twice as a module.....
So now your saying it happens when you have two menu modules on the same page.

I see reason to have two identical menus on the same page but I tested that way. The result was that the main menu displayed &

However if you use split menus(because the menu item only displays once) then the menu item showed just the &

Also if you create a menu item of Type 'Alias' and name it the same then just the & displays on both menu items.

The question is how often would a web designer have two copies of the same menu on the same page ? Would they be more likely to use split menus or create menu item of 'Type' Alias if they needed a menu item to appear in another menu ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Sun Aug 21, 2011 1:58 am

It always been 2 menus - sidebar is just a part of footer menu.

Your solution works, as well as mine with replacing & with 'and' :) This is just workaround and to be honest I have a lot of designs with menu on the top (or in footer) and then in sidebar just menu from a group this page belongs to. But never used & in the menu so haven't noticed it before.

Up to you if you're going to fix it or not. Should be a simple fix for someone who knows where to change it.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Sun Aug 21, 2011 2:02 am

pojke wrote:....
Up to you if you're going to fix it or not. Should be a simple fix for someone who knows where to change it.
Not up to me
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: amp and amp and... menu elements parsing

Post by infograf768 » Sun Aug 21, 2011 5:25 am

I confirm the issue, and it also shows in the breadcrumbs.
Although it is not good practice to display twice the same menu instead of using alias menu items, here is a solution:

Edit .../modules/mod_menu/helper.php
add after line 112

Code: Select all

$item->title = htmlspecialchars($item->title);
this line

Code: Select all

$item->title = str_replace('amp;amp;', 'amp;', $item->title);
It may not be the way to patch trunk but it works here.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

pojke
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Jun 16, 2011 4:49 am
Contact:

Re: amp and amp and... menu elements parsing

Post by pojke » Sun Aug 21, 2011 11:28 am

Thanks, works perfectly :)

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: amp and amp and... menu elements parsing

Post by Webdongle » Sun Aug 21, 2011 3:22 pm

infograf768 wrote:I confirm the issue, and it also shows in the breadcrumbs.
Although it is not good practice to display twice the same menu instead of using alias menu items, ...

....

It may not be the way to patch trunk but it works here.
Should there be a Tracker started for it ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: amp and amp and... menu elements parsing

Post by infograf768 » Sun Aug 21, 2011 3:56 pm

we have one
http://joomlacode.org/gf/project/joomla ... m_id=24628

as I said the issue is deeper and the code above is only a bandaid
(there are other ways than str_replace to do it anyway)
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
ChiefGoFor
Joomla! Champion
Joomla! Champion
Posts: 5614
Joined: Tue Sep 13, 2005 12:22 am
Location: Omaha, Nebraska, USA
Contact:

Re: amp and amp and... menu elements parsing

Post by ChiefGoFor » Mon Oct 03, 2011 7:01 am

Another solution that does not involve modifying core code is as follows:

We will use template overrides.
  • In your template's directory, go into the directory that is the same as your template's name.
  • You should see a folder called "html". If you do not see it, create it.
  • Create a folder called "mod_menu" in the "html" folder.
  • Copy the following three files from "\modules\mod_menu\tmpl" to the "mod_menu" directory you just created:

    Code: Select all

    default_component.php
    default_separator.php
    default_url.php
  • Now, open each of these files that are in the "\templates\<your_template>\html\mod_menu" folder.
  • Look for the following line (around line 14 or 15):

    Code: Select all

    $title = $item->anchor_title ? 'title="'.$item->anchor_title.'" ' : '';
  • Add the following line after the line you found above.

    Code: Select all

    $item->title = str_replace('amp;amp;', 'amp;', $item->title);
  • Save the files and test.
@JM - Good to see you. :)
Joomla! ...because open source matters
"Try to answer two questions for every one question you ask." - Me

bonsi
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jul 27, 2009 12:47 am

Re: amp and amp and... menu elements parsing

Post by bonsi » Mon Oct 10, 2011 12:43 am

I found this problem too. I have a second level menu down the left hand side of my site, replicating the second level drop-downs in the main menu.
I applied the template overrides, works grate, thanks to all.

User avatar
ChiefGoFor
Joomla! Champion
Joomla! Champion
Posts: 5614
Joined: Tue Sep 13, 2005 12:22 am
Location: Omaha, Nebraska, USA
Contact:

Re: amp and amp and... menu elements parsing

Post by ChiefGoFor » Mon Oct 10, 2011 2:50 am

I'm glad it helped. ... and welcome to the Joomla Forums! :)
Joomla! ...because open source matters
"Try to answer two questions for every one question you ask." - Me

kgriffin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Sun Jul 27, 2008 1:15 pm

Re: amp and amp and... menu elements parsing

Post by kgriffin » Mon Oct 10, 2011 5:30 pm

Thanks for the fix!

For anyone who is struggling with this in breadcrumbs, a similar fix can be done with template overrides. Once you have copied default.php into yourtemplate/html/mod_breadcrumbs, find line 20, which is:

Code: Select all

<?php for ($i = 0; $i < $count; $i ++) :


and right below it insert this line:

Code: Select all

$list[$i]->name = str_replace('amp;amp;', 'amp;', $list[$i]->name);
Cheers!

dontflinch
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sun Mar 06, 2011 2:03 am
Location: US

Re: amp and amp and... menu elements parsing

Post by dontflinch » Fri Jan 13, 2012 6:43 pm

thank you!

stusteel
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jan 19, 2012 3:18 am

Re: amp and amp and... menu elements parsing

Post by stusteel » Thu Jan 19, 2012 3:24 am

This looks like a satisfactory fix above but it exposes what seems like a logical error in the code.

This line in mod_menu/helper.php

Code: Select all

$item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''));
is running every time a menu is displayed in the page. It breaks if a menu is displayed more than once. The first time it runs it successfully escapes special characters. The second time it runs it is escaping the already escaped code.

If nothing else a re-assessment of the code and some refactoring might reduce double handling here.

Cheers,

zest96
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Sat Nov 24, 2007 10:38 pm
Location: ISRAEL
Contact:

Re: amp and amp and... menu elements parsing

Post by zest96 » Tue Apr 03, 2012 9:30 am

I'ts related to php version, see here.
http://no2.php.net/manual/en/function.h ... lchars.php

replacing the string amp; would not be a wise fix.

the fix
open mod_menu/helper.php
on line ~116 replace or comment:

Code: Select all

$item->title = htmlspecialchars($item->title);
with:

Code: Select all

$item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', FALSE);
this will ensure your localhost will work fine and also work when you upload the site to the server.
Oren Wassersprung - Joomla Israel
בניית אתרים בג'ומלה: http://www.joomla-israel.co.il


Locked

Return to “Joomla! 2.5 Bug Reporting”