Jump to content

Odd API use of "home" for name at certain points


MarcC
 Share

Recommended Posts

I ran into something crazy today. It seems like so fundamental of a bug or design issue that surely the root of the problem has to be some crazy server configuration issue on my webhost's end, but even if this is the case, Ryan and other PW devs should know about it.

Here is the simple test-case. My site has 4 pages below the root. Their names are about-us, member-info, articles, and site-map. Of these, about-us, member-info, and articles have subpages and can thus

be considered "categories." When I'm on the homepage, (that is, $page is '/'), if I do foreach ($page->children() as $child) { echo "{$child->name},"; } I get what you'd expect: about-us,member-info,articles,site-map,

OK, now navigate to a "category root" (2nd-level page, doesn't matter which one, I

tested them all). Let's say member-info. Let's get the same list as

before:

foreach ($pages->get('/')->children() as $child) { echo "{$child->name},"; }

I again get what you'd expect: about-us,member-info,articles,site-map,

Now the rub: navigate to a category child (3rd level page). Let's say /member-info/foobar/ . Let's attempt the same loop as above:

foreach ($pages->get('/')->children() as $child) { echo "{$child->name},"; }

The result? about-us,home,articles,site-map,

What? "home"? Sure enough:

echo $page->url; // Prints http://mysite.com/home/foobar/

echo $page->parent->name; // Prints home

echo $page->parent->title; // Prints Member Info [like it should]

echo $pages->get($page->parent->id)->title; // Also Member Info [like

it should]

echo $pages->get("/{$page->parent->name}/)->id; // 0, because there

is no page named "/home/"

So yeah. Basically most properties of the parent page seem to be correct, except name and things that involve name (like url). I have no clue why name is getting changed to "home". The siblings of the page in question are fine.

Anyway, thought you should know that it's happening. Any ideas to test are appreciated! This is the problem behind my issue with Soma's module.

This client is on a Pair Networks shared server.

Link to comment
Share on other sites

You wouldn't happen to have something like this executed on those 3rd level pages before the foreach?

$page->parent->name = 'home';

After that line everything works exactly the way you described. Don't know why you'd do that on purpose, but for example a missing second equals sign in an if statement would explain this.

  • Like 2
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...