Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:59:27+00:00 2026-06-09T22:59:27+00:00

I want to create a mobile website site, I’m trying to get my navigation

  • 0

I want to create a mobile website site, I’m trying to get my navigation to adapt to screen size. The HTML structure of the navigation is going to change, I’m aware that I can use CSS and @MEDIA calls. However, it doesn’t apply in my case, because I’m using a Foundation from ZURB framework, I need to change the elements, from UL to DD or DL, etc.

I looked around on several sources and I find that because PHP loads first before my AJAX is ready, I can’t get my navigation to display properly on mobile devices.

I needed some way to detect my screen size and communicate that value to my PHP menu generating function in Joomla.

I tried the following:

window.onload = function(){ 
var height = $(window).height();
var width = $(window).width();

 $.ajax({
    type: "POST",
    url: '',
    data: {
        "height": height,
        "width": width
    },
    success: function (data) {

    },
});
}

mod_menu sample:

<?php
   require_once('FirePHPCore/FirePHP.class.php');
   $firephp = FirePHP::getInstance(true);
   ob_start();

   $width = $_POST['width'];

   $firephp->group('Test Group');
   $firephp->log('Width');
   $firephp->log($width);
   $firephp->groupEnd();
?>

if ($width > 767) { 

?>

<!-- The class on the root UL tag was changed to match the Foundation nav style -->
<ul class="nav-bar<?php echo $params->get('class_sfx');?>"<?php
    $tag = '';
    if ($params->get('tag_id')!=NULL) {
        $tag = $params->get('tag_id').'';
        echo ' id="'.$tag.'"';
    }
?>>
<?php
foreach ($list as $i => &$item) :
    $id = '';
    if($item->id == $active_id)
    {
        $id = ' id="current"';
    }
    $class = '';
    if(in_array($item->id, $path))
    {
        $class .= 'current ';
    }
    if($item->deeper) {
        $class .= 'parent ';
    }

    $class = ' class="'.$class.'item'.$item->id.'"';

    echo '<li'.$id.$class.'>';

    // Render the menu item.
    switch ($item->type) :
        case 'separator':
        case 'url':
        case 'component':
            require JModuleHelper::getLayoutPath('mod_menu', 'default_'.$item->type);
            break;

        default:
            require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
            break;
    endswitch;

    // The next item is deeper.
    if ($item->deeper) {
        echo '<ul>';
    }
    // The next item is shallower.
    elseif ($item->shallower) {
        echo '</li>';
        echo str_repeat('</ul></li>', $item->level_diff);
    }
    // The next item is on the same level.
    else {
        echo '</li>';
    }
endforeach;
?></ul>
<?php } ?>

Then I use a if condition to check the width of the screen and choose the type of navigation. One navigation uses a UL structure, the other one has to use DL DD struture.

I used FirePHP to see how the page loads, my navigation doesn’t show up because the PHP loads first before the Ajax is ready, so I don’t see my navigation. I need my PHP to wait till the Ajax is ready or a portion of the page to wait. I’m not sure where to go from here.

I’m looking at Joomla MooTools, not sure if I can leverage that to wait for the Ajax to load before the page loads.

I’m aware, there are easier ways, like making a brand new menu item in Joomla or hiding things in Joomla to get it to work, but I want a more clean and elegant way.

If anyone has any code samples. Please post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:59:29+00:00Added an answer on June 9, 2026 at 10:59 pm

    The solution is to identify by browser:

    User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
    

    I found a good guide here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having problem when i want to create mobile optimization in my site,i'm read
i'm trying to make a live search for my mobile website, I don't want
I want to create a mobile version of a site that I frequent often.
I want to create a mobile app for an exisiting website that runs on
I am using this site template to create a mobile/iPhone friendly site. I want
I'm still trying to figure out a way to get a mobile site running.
I am now going to develop a mobile website both support common html format
I want to create this effect in mobile safari. http://jqueryfordesigners.com/demo/header-slide.html I'm using iScroll 4.
I've been trying to create a site with the following structure: But I can't
I want to use JQuery Mobile to create an html page. As they told

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.