Jump to content

Obtain the current url according to the language id


it.ti.teczo

Recommended Posts

Hello, I'm new to web programming with Prestashop 1.7

I'm having a problem with this.

My website is in English, Vietnamese. And I get the current page link to share facebook this way:

<a href="http://www.facebook.com/sharer.php?u={$urls.current_url}">

The trouble is that when I use the web in Vietnamese, {$ urls.current_url} will be in Vietnamese url. When I use the web in English, {$ urls.current_url} will be in the English url.

I do not want that.

I want the URL fixed in Vietnamese language. This means that even if you surf the web, it will only take the current page URL with the id of the Vietnamese language.

I need some help.

Sorry for my english.

Thank you.

Link to comment
Share on other sites

8 hours ago, musicmaster said:

Smarty is a language. So you can do operations in it. In your case that would mean that you would replace

{$urls.current_url}

with

{$urls.current_url|replace: '/en/' : '/vn/'}

Hi, thank you.

I have done your way. It works but not perfect. Not my intention.

For example:

Use: {$urls.current_url|replace: '/en/' : '/vn/'}

  1. Web language: Vn => aabbcc.c0m/vn/trang-chu.html
  2. Web language: En => aabbcc.c0m/vn/home.html (instead of: aabbcc.c0m/en/home.html)

I do not want that.

I want:

  1. Web language: Vn => aabbcc.c0m/vn/trang-chu.html
  2. Web language: En => aabbcc.c0m/vn/trang-chu.html

I need some help.

Sorry for my english.

Thank.

Link to comment
Share on other sites

Problem when using facebook comment.

Web language: Vn

<div class="fb-comments" data-href="https://###.com/vn/sony/ong-kinh-sony-fe-70200gm.html" data-numposts="5"> </div>

Web language: En

<div class="fb-comments" data-href="https://###.com/en/sony/sony-fe-70-200mm-f28-gm-oss-lens.html" data-numposts="5"> </div>

There are 2 different comments on 1 product due to different urls.

I use 

<div class="fb-comments" data-href="{$urls.current_url}" data-numposts="5"> </div>

 

Edited by it.ti.teczo (see edit history)
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...