Author Topic: Pass the SEF'ed URL into php?  (Read 4108 times)

andyweb

  • Newbie
  • *
  • Posts: 5
    • View Profile
Pass the SEF'ed URL into php?
« on: 25 May 2007, 04:09 »
Hi, I was wondering if there was any way I could pass the SEF version of the URL into PHP? (I have a php script included in the index.php template file)

Using "sefRelToAbs($_SERVER['REQUEST_URI']);" only gets me the "dirty URL" unless I have defined an alias.

Thanks
« Last Edit: 25 May 2007, 04:12 by andyweb »

Saka

  • Administrator
  • Hero Member
  • *****
  • Posts: 2,500
    • View Profile
    • Sakic.Net
Re: Pass the SEF'ed URL into php?
« Reply #1 on: 25 May 2007, 11:42 »
sefRelToAbs( substr( $_SERVER['REQUEST_URI']), 1, strlen($_SERVER['REQUEST_URI'])-1 ) ); should work if Joomla is installed in root.

andyweb

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Pass the SEF'ed URL into php?
« Reply #2 on: 25 May 2007, 13:23 »
Thanks, but echo'ing that returns nothing, hrmmm. My joomla is installed in the root.

Excuse my ignorance ...but I don't quite understand how that code would help any though.

Thing is I don't want to return the, eg: /index.php?option=com_content&task=view&id=8&Itemid=23
I'd like to return the SEF'ed version of the URL, eg. /section/category/page-name.html

Is this possible?

PS. I noticed there seemed to be an extra bracket in there, so removed one at the end as the page was breaking at that point.

andyweb

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Pass the SEF'ed URL into php?
« Reply #3 on: 30 May 2007, 14:13 »
Well not to worry, I got it ...the command I was after was:

sefRelToAbs($_SERVER['REDIRECT_URL']);

it-info

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Pass the SEF'ed URL into php?
« Reply #4 on: 31 May 2007, 17:33 »
Well not to worry, I got it ...the command I was after was:

sefRelToAbs($_SERVER['REDIRECT_URL']);

Where to put htis an what are the benefits?

Regards, Christian

andyweb

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Pass the SEF'ed URL into php?
« Reply #5 on: 05 June 2007, 12:27 »
Well, I was using this to serve specific banners to the various sections I have on my website.

So I was pulling the sef url, then using the explode function in php to extract the section name and using that name to serve the specific banner I wanted.

I'm sure there can be many uses for it...

it-info

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Pass the SEF'ed URL into php?
« Reply #6 on: 05 June 2007, 18:14 »
Well, I was using this to serve specific banners to the various sections I have on my website.

So I was pulling the sef url, then using the explode function in php to extract the section name and using that name to serve the specific banner I wanted.

I'm sure there can be many uses for it...

Thats a very great idea.... diefferent invocation-codes for different cats/sections......
Currently i mange that via hundreds of custom-modules, publish in the specified menu-entry for a cat/section.

Regards, Christian