Jump to content

urlSegment[n] not working


Valery
 Share

Recommended Posts

Hi friends,

Being a tiny bit lazy, I copied the $input->urlSegment[n] code from the description of "Allow URL segments" in the template settings.

Up to 3 URL segments are supported after the page URL. These may be any combination of lowercase ASCII letters (a-z), numbers (0-9), dashes and underscores. You can access the URL segments from your template API code by referencing the $input->urlSegment(n) function or $input->urlSegment[n] property (replacing [n] with 1, 2 or 3).

However, that did not work (actually, it displays a character at position n).

I scanned through up my older code and saw that I used $input->urlSegment(n) elsewhere and it worked just fine.

So, the question is probably to Ryan: does the description of "Allow URL segments" need an update? Otherwise, please correct me.

Link to comment
Share on other sites

As it might be obvious, i'll just ask it anyway, did you put a number from 1 to 3 in your code in the place where the n is? The character n represents a number.

echo $input->urlSegment(1);

Also, you must have URL segments turned on for the related template, and last but not least you must have a urlSegment in your URL.

Lets say your page with a template that has urlSegments turned on is located at:

http://yourdomain.com/foo/

Then if you visit it at the following URL the $input->urlSegment(1) will print "bar"

http://yourdomain.com/foo/bar/

Edit: replaced [1] with (1)

Edited by Raymond Geerts
  • Like 1
Link to comment
Share on other sites

$input->urlSegment[n] property (replacing [n] with 1, 2 or 3).

it .say replace: [n]

not: n

u have: 

   $input->urlSegment[n]

 nexts u find: [n]

    u replace [n] with: 1 , 2 , or  3

u get

$input->urlSegment1

                                       $input->urlSegment2

$Input->urlSegment3

  • Like 4
Link to comment
Share on other sites

 ... or $input->urlSegment[n] property (replacing [n] with 1, 2 or 3).

$input->urlSegment[n] property  (not array!)

replacing [n] with 1, 2 or 3  (not replacing n with 1, 2 or 3)

$input->urlSegment1, $input->urlSegment2 or $input->urlSegment3

  • Like 3
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

×
×
  • Create New...