Solved

Empty span output problem with PHP + Joomla

Posted on 2010-09-18
7
706 Views
Last Modified: 2013-11-19
I am working on a custom template for Joomla but am having a problem with menu items. When a separator is created it has an invalid empty 'span' element
<span />

Open in new window

. How can I force the output of this to
<span></span>

Open in new window

?

This is causing the entire page to break in all versions of IE.

All I am doing is calling the following function:
modMainMenuHelper::render($params);

Open in new window

0
Comment
Question by:numberkruncher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 33710917
That span element is perfectly valid XHTML.  Are you using doctype STRICT?

See this note - It is a problem with IE, not with the XHTML:
http://www.thismuchiknow.co.uk/?p=184

So thanks again, Microsoft.

If you find the render method, you might be able to add this line of code.  Adjust the variable name from $html to whatever is used to render the output string.

HTH, ~Ray
$html = str_replace('<span />', '<span></span>', $html);

Open in new window

0
 
LVL 13

Author Comment

by:numberkruncher
ID: 33710937
> Are you using doctype STRICT?

I am using the XHTML1 transitional doctype, but I did try strict to see if it made any differences...unfortunately it didn't.

> So thanks again, Microsoft.

Tell me about it!

> If you find the render method, you might be able to add this line of code...

Yes, looks like that will have to be the solution. Unfortunately the render method also inserts
  • . I was hoping that I had missed a switch or something in PHP which would revert to IE-safe code.

    The thing that I do not understand is, when I switch to the HTML4-strict doctype, the PHP script still outputs self-closing span tags... This isn't right is it?
    0
     
    LVL 13

    Author Comment

    by:numberkruncher
    ID: 33710940
    Yes, looks like that will have to be the solution. Unfortunately the render method also inserts <li />. I was hoping that I had missed a switch or something in PHP which would revert to IE-safe code.
    0
    Independent Software Vendors: We Want Your Opinion

    We value your feedback.

    Take our survey and automatically be enter to win anyone of the following:
    Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

     
    LVL 110

    Expert Comment

    by:Ray Paseur
    ID: 33710966
    I'm not aware of any such switch, but leave the question open and maybe a Joomla expert will have a magic wand for this situation.

    You can, of course, do the same kind of str_replace() with the LI tag and any others that are mishandled by the Microsoft browsers.
    0
     
    LVL 42

    Expert Comment

    by:David S.
    ID: 33712630
    Could you avoid having the empty list-items (<li>)? They're not really semantically correct anyway.

    Sometimes I can just add styles (e.g. a background image) to the list itself. Other times I end up adding an additional wrapper <div> around a list in order to be able to move empty <li>s.
    0
     
    LVL 13

    Author Comment

    by:numberkruncher
    ID: 33712670
    The menu item is defined using the Joomla UI. The XHTML is generated by "modMainMenuHelper::render".

    Everything except the templates are entirely Joomla.
    0
     
    LVL 13

    Author Closing Comment

    by:numberkruncher
    ID: 33794745
    Thanks, sorry for the late response.
    0

    Featured Post

    On Demand Webinar - Networking for the Cloud Era

    This webinar discusses:
    -Common barriers companies experience when moving to the cloud
    -How SD-WAN changes the way we look at networks
    -Best practices customers should employ moving forward with cloud migration
    -What happens behind the scenes of SteelConnect’s one-click button

    Question has a verified solution.

    If you are experiencing a similar issue, please ask a related question

    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    739 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question