Menu in PHP and HTML

Asked

Viewed 841 times

1

I need you to ask me a question, I created a page and put the menu in PHP. Follow data:

php menu.

<div class="col-md-9 text-left float-left collapse-navation">
    <div class="navbar-collapse collapse navbar-inverse no-transition">
        <ul class="nav navbar-nav navbar-left">
            <li><a href="../index.html">Home</a></li>
            <li><a href="../#sobre">Sobre</a></li>
            <li><a href="../#work">Destaques</a></li>
            <li><a href="../#titulos">Títulos</a></li>
            <li><a href="../#testimonial">Testemunho</a></li>
            <li class="last"><a href="../#contato">Contato</a></li>
        </ul>
    </div>
</div>

And I put in another page include.php:

<?php
include ('../menu.php');
?>

But when the menu enters the page the links created do not work when you click on them, only working if you right-click and open in new tab. What could it be? The problem is just this, the links.

My server is from Locaweb.

  • I see that you are using relative urls, see if the file where you are setting include actually finds a level below the menu.php file.

  • Hello Diego, it is yes; so much so that when I right click and open in new tab it opens correctly. My question is if the code is correct, or if it could be from the server, in the case Locaweb; or if I need to check if it is conflicting with some javascrip of the page.

  • 1

    Another thing, why that "#" before the links? you’re using anchors?

  • The site is a Onepage, I created an ID with the names, use the # to go where the excerpt of this onepage starts, would be: index.html#contact; when you click this goes to the contact part of this onepage

  • In fact, anchors you reference using the "name" in the link tag. Switch to <a name="about"></a> and test.

  • I’m almost sure your problem is related to javascript... it would be good to put the javascript code too

  • If you’re using these # to go to another corner of the Onpage I did not understand what the doubt regarding PHP...

  • 1

    Good I got it! Responding to the comments: Diego, I did and it worked in this case tbm... the problem was a js identified and I will correct. Rafael this page I’m creating is a new, not part of onepage. Thanks guys for the help! It worked now.

  • 1

    collapse-navation ? The class name in bootstrap would not be collapse-navigation ?

Show 4 more comments

2 answers

1

This type of links will only work on the page itself, or with the javascript execution.

The way the code is, I see it’s returning to another.

0

When you make use of #ocorrencia in the URL, means you are pointing to an anchored place of your page.

It will go through until you find the occurrence on the same page <a name="ocorrencia" id="ocorrencia"></a>, and in this case it makes no sense you put "../" mapping the address before that, because it will be ignored by the anchor, because when you click will not change your page, nor with "reza brava". An example of using a link per grid (#) that would change the page is by creating routes using Angular JS, but from there comes ajax technology in the middle, which doesn’t have much to do with what you’re doubting, apparently.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.