Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Empty span output problem with PHP + Joomla

Posted on 2010-09-18
7
Medium Priority
?
709 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 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

    Technology Partners: 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!

    Question has a verified solution.

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

    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    This article discusses four methods for overlaying images in a container on a web page
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    722 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