-1

I'm working on a scrollable one-page website, in which each div represents a different section. For example, url is dynaone.com/index.php, and when I click on the menu's different buttons, it changes to /index.php#s1, #s2, #s3, and so on. In section nº 2 I added another menu that works with php GET, in a way that when you click on one of the buttons, it redirects you to index.php?id=1 and so on. Of course when I first tried it, it scrolled me back to the top of the page, 'home', as I wasn't specifying the section. But when I did, assigning "index.php?id=1#s2" to the first element in the inner menu, it redirected me to section 1. It doesn't matter which number I write after "#s", it will keep putting section nº 1 on top of the page.
I'm using SMINT's demo as a base, adjusting it to my website's needs, but I couldn't find anything related to GET method issues on the plugin's page. I would really appreciate some help with this, as it's very annoying having to go back everytime I click to correctly view section nº 2.

This is part of my inner menu:

        <div id="botonera_productos"><ul>
        <li><a href="index.php?id=1#s2"> Quemadores</a> </li>
        <li><a href="index.php?id=2#s2"> BCAAs</a></li> </ul> </div>

This is my php section:

if(@$_GET['id']==1) {
                ?>

                <figure><img src="imagenes/quemadores/1.jpg"><figcaption> ULTIMATE L-CARNITINA 500 60 TABS - <b>$330</b> </figcaption></figure> 
<?php } ?>

And this is the site's main menu:

<nav class="subMenu" >
    <div class="inner">
        <a href="#sTop" class="subNavBtn">Home</a>
        <a href="#s1" class="subNavBtn">Nosotros</a> 
        <a href="#s2" class="subNavBtn">Productos</a>
        <a href="#s3" class="subNavBtn">Local</a>
        <a href="#s4" class="subNavBtn">Envíos</a>
        <a href="#s5" class="subNavBtn">Consultas</a>
        <a href="https://www.facebook.com/dynaone" class="subNavBtn extLink end" target="_blank">Facebook</a>
    </div>
</nav>

Thank you.

  • 2
    Anything after the `#` is not sent to PHP. – John Conde Oct 13 '15 at 02:03
  • @JohnConde Thank you for your answer. So, is there a way to do what I want to do and avoid this issue? – patamfreti Oct 13 '15 at 02:13
  • yup, jsut dont use them –  Oct 13 '15 at 02:16
  • @Dagon is there an alternative to # to specify a section in the url? – patamfreti Oct 13 '15 at 02:18
  • dont see the php usinging the anchor –  Oct 13 '15 at 02:33
  • @Dagon, sorry, I don't get what you mean – patamfreti Oct 13 '15 at 02:36
  • i don't really get the question is my problem. –  Oct 13 '15 at 02:38
  • @Dagon I get index.php?id=1#s2 doesn't lead me anywhere because anything after # is not sent to PHP, as john told me before. So I was asking if there's an alternative to "#s2" to specify that I want the browser to show me a specific section after index.php?id=1 is interpreted. – patamfreti Oct 13 '15 at 02:45
  • but i don't see what php even has to do with it, its not php that uses the # its the browser if the url on the screen shows `index.php?id=1#s2` then you should be sent to the `s2` anchor point –  Oct 13 '15 at 02:55
  • @Dagon it sends me to s1 no matter what I write, I only say it's related to php as that's what the first answer said – patamfreti Oct 13 '15 at 03:07

1 Answers1

0

The question isn't very clear but basically:

The anchor is an HTML construct. So once the page is already loaded, you can use #whatever to take you to wherever on that page that the anchor has been defined; ala <a id="whatever">

The PHP arguments, like ?id=1 - a new page will be loaded depending on what you use here.

You can use anchors in conjunction with a PHP page (ie. a PHP page may have multiple anchors) but you cannot load a new page with anchors alone.

Maybe Javascript will help you achieve what you want to do. With AJAX calls and the like then there are far less restrictions on how you load data.

b85411
  • 8,054
  • 10
  • 54
  • 109
  • Thank you very much for the explanation, I get it now. Can you explain to me how to use AJAX in this case? I'm new to this topic and I've never used it. – patamfreti Oct 13 '15 at 03:28
  • It may not be required, but if you were to use AJAX you could truly make it a one page website. For example instead of having `?id=1`, `?id=2`, etc you could just have it so when a certain button is clicked the data on the page reloads but the page itself does NOT reload. – b85411 Oct 13 '15 at 03:32
  • that would be great! I guess I'll just have to learn how to use it – patamfreti Oct 13 '15 at 03:39