Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Empty span output problem with PHP + Joomla

Posted on 2010-09-18
7
Medium Priority
?
711 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
  • 4
  • 2
7 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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
    VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

    Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

     
    LVL 111

    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 43

    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

    Free Tool: Port Scanner

    Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

    One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

    Question has a verified solution.

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

    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    This article discusses how to implement server side field validation and display customized error messages to the client.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
    Suggested Courses

    824 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