Jump to content

2 axis navigation


nerotic

Recommended Posts

This is a newbie question, very limited understanding of PHP.

 

For a site that I'm working on: http://nerotic.net/aux/

 

I have X-Y navigation as you can see (top: sound,level,box,classic,shop - left: why,what,how,where,who).  These elements never change anywhere on the site, except in shop where they disappear but that's really neither here nor there.

 

Because of different needs in templating between the Sound/Level/Box/Classic/Shop areas each one has its own PHP file which then uses php includes in the content area div so that the left nav is getting reloaded each time there's a switch to another top nav section.

 

At all times one X and one Y will always be "lit" up (still getting the CSS in order for this one). The homepage is SOUND/WHY.  So if you click on what..you're now at SOUND/WHAT-

 

Here's what I'm trying to accomplish but not sure how. If youre on SOUND/WHAT and click on BOX...you should land at BOX/WHAT rather than BOX/WHY and if you're on LEVEL/WHO and click on CLASSIC you end up at CLASSIC WHO.

 

I assume that I need to set a global variable to capture which Y axis point I'm on:

 

define("y_coord","$ycoord"); 

 

 

However, what I don't know how to do is to tell the page which is the current variable.

 

Apparently I'm not even searching correctly for answers.  If anyone could lend me a hand or even point me to a post/tutorial that would help I'd be greatly appreciative.

 

Thanks.

 

 

Link to comment
Share on other sites

i dont know exactly what 2 axis navigation is or does, but i would just pass two variable values around the place, maybe in a session value: $_SESSION['x'] and $_SESSION['y'].

 

you can generate what page you need based off the value or those two values? or no?

Link to comment
Share on other sites

i dont know exactly what 2 axis navigation is or does, but i would just pass two variable values around the place, maybe in a session value: $_SESSION['x'] and $_SESSION['y'].

 

you can generate what page you need based off the value or those two values? or no?

 

Think of it as a 5x5 matrix:

 

    x x x x x

y

y

y

y

 

The nav never changes and it's going to give us a much clearer way for users to compare data on the products.

 

In any event, I could technically do it the way you described by concatenating two variable to form a page name...and in the end this is what it's actually going to do, just that the 1st part will be hardcoded (i.e. won't use a variable).

 

I understand that I need to use a session varaible, what I don't know how to do is create and have the page store that variable. That's actually what I was asking :)

Link to comment
Share on other sites

so in order to pass this how would I have to construct a link...would it look something like this?

 

<a href="classic.php?content=who">who</a>

 

 

 

from memory:

session_start();
$_SESSION['x'] = "foo";
$_SESSION['y'] = "bar";

 

or you could just pass values around in $_GET or $_POST

Link to comment
Share on other sites

Ok..I've taken a new tack, using what I understand.

 

In the include files I've added the following.

 

In sound-where.php (which is being included by index.php) I have this line of code:

 

<?php $nav = "where"; ?> 

 

Then in index.php I have the following at the top of the document:

<? session_start();
$_SESSION["section"] = $_POST["nav"];
echo $_SESSION["section"]; 
?>

 

 

And then later I'm constructing my links as such:

<a href="level.php?page=level<?php echo $section;?>" class="tnav">
<a href="box.php?page=box<?php echo $section;?>" class="tnav">
<a href="classic.php?page=box<?php echo $section;?>" class="tnav">

 

 

I'm not getting anything back from $nav though...blank.  Can anyone tell me what I'm doing wrong?

 

Thanks.

Link to comment
Share on other sites

<?php
echo "x was: ".$_GET["x"]."<br>";
echo "y was: ".$_GET["y"];

?>

<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input name="x"><br>
<input name="y"><br>
<input type="submit" value="submit">
</form>

 

Above is a very simple form, which let you enter 2 values, and when submitted these 2 values are returned.

I think this can be used in your original problem to store your 'top' and 'left' elements..

 

Link to comment
Share on other sites

Are you posting anything to the page at all times? If nothing is in $_POST["nav"] it's going to be blank...

 

I don't understand the question. What element is missing? I've shown all the code that I'm using.

 

And another question I have, do I need to open php sessions on all pages on the site in the event that people enter via a deep link?

Link to comment
Share on other sites

Are you posting anything to the page at all times? If nothing is in $_POST["nav"] it's going to be blank...

 

I've changed the code to this in the index.php:

 

<? session_start();
$section = $_SESSION["nav"];
echo $section; 
?>

 

 

and this in the file that's being included:

 


<?php 
$nav = "who"; 
echo $nav;
?> 

 

In the included file the echo is working just fine, it's just not making it back to the index.html

Link to comment
Share on other sites

In the end it was simple enough:

 

Muffins dropped this little nugget on me:

 

you need to set $_SESSION["nav"] somewhere

 

so this:

 

<?php 
$nav = "who"; 
echo $nav;
?> 

became this:

<?php

$_SESSION["nav"] = "who";

?>

Link to comment
Share on other sites

There's one more issue here...

 

Technically everything is working just fine in terms of passing the variable. One unforeseen issue that has come up is since the $_SESSION "nav" is being set in an included document that's streamed into an overarching template the variable doesn't update in the template until the page is reloaded which means that the navigation is always one step behind what the user actually just clicked on.

 

How can update the session variable w/o refreshing the page?

Link to comment
Share on other sites

Rethinking what your pages are doing, I think what you said below may be a simpler way to get what you want done.

 

so in order to pass this how would I have to construct a link...would it look something like this?

 

<a href="classic.php?content=who">who</a>

 

from what i remember of your page, "classic" is the first value (X) and "content=who" is the second value (Y) isn't it? the value of content will be passed around in $_GET (as long as each link the user clicks has a ?content=value part) and the other value is always defined by the page name.

Link to comment
Share on other sites

Hey Catfish,

 

Thanks for replying.  I should have marked this forum solved but until now I hadn't seen the green button...too obvious I suppose :)

 

I've actually moved onto bigger and better problems:

http://www.phpfreaks.com/forums/index.php/topic,303153.0.html

 

If you have any insight there I'd be grateful :)

 

Rethinking what your pages are doing, I think what you said below may be a simpler way to get what you want done.

 

so in order to pass this how would I have to construct a link...would it look something like this?

 

<a href="classic.php?content=who">who</a>

 

 

 

from what i remember of your page, "classic" is the first value (X) and "content=who" is the second value (Y) isn't it? the value of content will be passed around in $_GET (as long as each link the user clicks has a ?content=value part) and the other value is always defined by the page name.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.