Jump to content

$page->next devaluated/replaced?


Recommended Posts

Hi guys and gals!

I'm pretty new to ProcessWire, and trying to figure out as much as I can myself, but I'm totally stuck on this little piece though.

• I've got a one-page scrollable site, and am using hashtags to jump to the next area (which is incidentally of course also a $page)

• what I'm looking to do is link the next-page to an href, so I figured I could use $page->next, but that gives me a number (1007 in this case). Same goes for the siblings.

What I thought would happen would be the following; just as $page->name gives me the current name (and thus the current hashtag) I figured 'next' would give me the name of the 'next' page. But I probably didn't do my homework.

$page->next->name gives me 1007->name so that clearly isn't working. So to end this query:

How do I get the name of the next page displayed so I can use it in my href?

thanks for the help!


->next is shown here: http://processwire.com/api/variables/page/

but not here: http://processwire.com/api/cheatsheet/

Link to comment
Share on other sites

Hi and welcome to the forums!

You're definitely on the right track, just a little PHP to be learned I think :). I guess you've tried something like this:

echo "$page->next->name";

To make it work you need to add some curly braces, like this:

echo "{$page->next->name}";

And probably you're actually after url rather than name (as Soma says above, it seems).

Link to comment
Share on other sites

Next is shown on cheatsheet aswell. So next gives you the next page in the tree or array and if you echo it it gives you the id only, so you have to add the field you need , in your case ->name.

  • Like 1
Link to comment
Share on other sites

Hey nik & Soma! first off; thanks for the quick replies! :D

Both right - I did have the 'advanced' disabled, so I didn't see the ->next, won't make that mistake again anytime soon,

and indeed, some php was to be learned, the curly braces did it!

I ended up using ->name, because I'm echoing it into an href reference, and using hashchange event to scroll down to the correct page

it's working now though, so thanks again!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...