Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

get full url path but without parameter

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Thu Oct 17, 2013 10:29 am    Post subject: get full url path but without parameter Reply with quote

Hi,
which smarty variable gives me the url path without parameters.
Example:
I have an url like this: http://www.mydomain.com/myfolder?p=3

I want to get http://www.mydomain.com/myfolder

With {$smarty.server.HTTP_HOST} I get "http://www.mydomain.com" and with {$smarty.server.REQUEST_URI}I get /myfolder?p=3

So what can I use in my case?
Thanks in Advance!
Malte
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Oct 17, 2013 1:43 pm    Post subject: Reply with quote

Look at the output of phpinfo(), it will give you the apache _ENV vars, this is what $smarty.server is giving you. You are probably looking for something like SCRIPT_URI
Back to top
View user's profile Send private message Visit poster's website
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Thu Oct 17, 2013 2:05 pm    Post subject: Reply with quote

I see this in the php info:
safe_mode_allowed_env_vars PHP_
safe_mode_protected_env_vars LD_LIBRARY_PATH

Both don't work.

{$smarty.server.SCRIPT_URI} just gives me "http://www.mydomain.com".

I am not sure, if it is an issue of the Shop software Shopware, which uses the smarty engine.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Oct 17, 2013 2:23 pm    Post subject: Reply with quote

look for something like this in your phpinfo output:

http://d.pr/i/f4Np

judging by that, I'd say SCRIPT_FILENAME is what you are after.
Back to top
View user's profile Send private message Visit poster's website
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Thu Oct 17, 2013 2:30 pm    Post subject: Reply with quote

{$smarty.server.SCRIPT_FILENAME} shows
"/var/www/web1/html/shop/shop_4/shopware.php?p=3"
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Oct 17, 2013 2:39 pm    Post subject: Reply with quote

oops that is the filepath.

SCRIPT_URI should give you the full URL without the query string.

Put something like

http://www.mysite.com/phpinfo.php?abc=123

and check the output, see which one does not contain ?abc=123
Back to top
View user's profile Send private message Visit poster's website
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Thu Oct 17, 2013 3:58 pm    Post subject: Reply with quote

I think it is also a SEO issue.

I opened: http://www.mydomain.com/test/phpinfo.php?abc=123

and it says:

_SERVER["REQUEST_URI"] /test/phpinfo.php?abc=123
_SERVER["SCRIPT_NAME"] /test/phpinfo.php


So I tried it with the Shop and a Category:
http://www.mydomain.com/category?p=3

with the variable {$smarty.server.SCRIPT_NAME} but it only outputs:
"/shopware.php"

Very strange
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Oct 17, 2013 5:35 pm    Post subject: Reply with quote

what does SCRIPT_URI give you?
Back to top
View user's profile Send private message Visit poster's website
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Fri Oct 18, 2013 7:14 am    Post subject: Reply with quote

With {$smarty.server.REQUEST_URI}I get /category?p=3
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 18, 2013 1:21 pm    Post subject: Reply with quote

SCRIPT_URI should be what you need. What is this for, a link? a relative link should work fine in a browser too (no host name)
Back to top
View user's profile Send private message Visit poster's website
StingerMKO
Smarty Rookie


Joined: 17 Oct 2013
Posts: 6

PostPosted: Tue Nov 05, 2013 2:46 pm    Post subject: Reply with quote

{$smarty.server.SCRIPT_URI} Does not work in a Shopware template. It returns nothing (empty).
I think what I need is not possible Sad
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP