Jump to content

$input->urlSegment1 returns nothing?


FuturShoc
 Share

Recommended Posts

For some reason,  $input->urlSegment1 isn't returning a value. Nor is  $input->urlSegment2,  $input->urlSegment3, etc.

I'm just trying:

echo $input->urlSegment1;

... but there *ARE* segments in these positions of the page.

For the record, I have enabled "Allow URL segments" for that template in PW's control panel.

Link to comment
Share on other sites

It doesn't work for me, despite the enabled template and $config->maxUrlSegments config entry being set up.

Is there any other factor which might prevent it?



Ok, I've experimented with adding segments to my page URL and I think I see part of the problem.

My development base url is this:

http://domain.com/clients/lrpa/web/

My page url which doesn't echo my URL segments as expected is:

http://domain.com/clients/lrpa/web/business-industry/

However, if I add another segment, like this...

http://inthooz.me/clients/lrpa/web/business-industry/test

It recognizes "test" as segment 1.

SO, it appears that my base url has too many subdirectories which is interfering with PW's segment variables.

Is there anything I can do to counteract this affect?

Link to comment
Share on other sites

That would be 5 segments... what if you set up the max segment count in config.php?

Edit: Maybe not really, as the segments are counted from the page url, I don't know of what would prevent it from working. Any modules installed third party? Anything that messes with page view or render or urls?

Link to comment
Share on other sites

I don't really understand what you're trying to say, but I can have as many levels and segments still work perfect.

http://pw2-dev.ch/about/what/again-another/level/test/ 

...is a page

http://pw2-dev.ch/about/what/again-another/level/test/xxx

I get xxx as the $input->urlSemment1

Edit: Just to make sure the segments you're trying doesn't actually resolve to a page? Because if PW finds a page it won't have url segments.

  • Like 1
Link to comment
Share on other sites

It doesn't work for me, despite the enabled template and $config->maxUrlSegments config entry being set up.

Is there any other factor which might prevent it?

Ok, I've experimented with adding segments to my page URL and I think I see part of the problem.

My development base url is this:

http://domain.com/clients/lrpa/web/

My page url which doesn't echo my URL segments as expected is:

http://domain.com/clients/lrpa/web/business-industry/

However, if I add another segment, like this...

http://inthooz.me/clients/lrpa/web/business-industry/test

It recognizes "test" as segment 1.

SO, it appears that my base url has too many subdirectories which is interfering with PW's segment variables.

Is there anything I can do to counteract this affect?

Still I'm not sure I understand, as it seems to be working.

What was the problem again? No matter what I try it always works as it should.

Link to comment
Share on other sites

Maybe just confusion about urlSegments vs parent pages? UrlSegments relate to urls that doesn't have page.

That's what I'm wondering too. My best guess is that he's expecting business-industry to be urlSegment1, but business-industry is actually the name of the page.

Link to comment
Share on other sites

Thanks for everyone's input. I understand now, though I don't think it was unreasonable for me to expect URL segments to begin right after the base url.

Now that I understand the expectation, I can certainly use page name to refer to that segment.

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

  • Recently Browsing   0 members

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