Solved

Empty span output problem with PHP + Joomla

Posted on 2010-09-18
7
699 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 108

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
    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

     
    LVL 108

    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

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
    The viewer will learn how to dynamically set the form action using jQuery.
    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…

    706 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now