Jump to content

Smarty Variables for URL / URI values


Recommended Posts

Hopefully others can expand on this.

I find it to be a useful cheat sheet.

 

{$smarty.server.REQUEST_URI} gives everything under the domain name

e.g. /mydir/en/helloworld.html

 

{$base_dir} gives the fully qualified domain name AND the base directory

e.g. http://www.mydomain.com/mydir/

 

{$smarty.server.HTTP_HOST} gives the domain name only

e.g. www.mydomain.com (without the http prefix)

 

{$lang_iso} gives the current language locale

e.g. en

e.g. ja

 

 

 

Would be interesting to know how to return JUST the base directory

e.g. /mydir/

 

and how to get the current page uri minus the base directory

e.g. /en/helloworld.html

 

and hot to get just the page without any preceding qualifiers

e.g. /helloworld.html

 

Are there Smarty variables for these?

Link to comment
Share on other sites

  • 2 months later...

So lets say I have an image MyPic.jpg and it's in a folder /mypictures/ under the current theme.

 

What is the correct way to link to the image in a TPL file?

 

I usually end up hard coding everything under the {$base_dir} variable, which I know is not correct.

Link to comment
Share on other sites

  • 3 months later...

Hi Guys...

 

I'm having issues with things loading in https when using the smarty variable {base_dir} - is there a way to use {base_dir} but EXCLUDE the http portion in the output?

 

So basically {base_dir} gives me "http://myshop.com/myshopfolder" but I want just "myshop.com/myshopfolder"

 

(I have more than 1 site on the same server...so I need to specify the shops folder...) {base_dir} does what I need it to do...but it adds the http...which I don't want...

 

Did you guys happen to come across a variable for this?

Link to comment
Share on other sites

  • 2 years later...

HI! I don't know if you ever resolved this but I found a great solution.

 

Turn: 13-mycatagory?p=4

 

into: 13-mycatagory

 

by using the strtok operator in php.

 

{assign var="currentPage" value=strtok($smarty.server.REQUEST_URI,'?')} {* page name without query/ parameters*}

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...