Jump to content

how to get last url path


kkalgidim
 Share

Recommended Posts

							<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
								<?php foreach($pages->get("/treatments/")->children as $t) {
								
					   
									$count = $pages->count("template=clinic, cliniclocation=$page->id, treatmentprice.clinictreatments=$t->id");
									if ($count!=0){
										
									echo "<a class='dropdown-item' href='$page->url$t->name'>$t->title ($count)</a>";}
								} ?>
							</div>

 

Hi you see code above.

Its a multi language web site.

When i change the language instead of default language,  url section ( t->name  ) not  change!

for ex: 

default language english

http://www.domain.com/en/locations/turkey/dental-implant

select turkish language

http://www.domain.com/tr/konumlar/turkey/dental-implant

it must be 

http://www.domain.com/tr/konumlar/turkey/dis-implanti

 

if i use

$t->title 

instead of

$t->name

translation works fine but not as url. as usual it echoes title

it look like 

http://www.domain.com/tr/konumlar/turkey/Dis Implati

 

if i use $t->url

it echo konumlar/turkey/dis-implati

 so if i get last segment of url it will works fine.

 

What can i do for that?

 

Link to comment
Share on other sites

Hi,

Did you installed the following core module ? : LanguageSupportPageNames

It allow you to define a specific page name for each language and editing them in the tab Page > Settings of a page. (I think you are missing this one).

Capture.thumb.PNG.7904b25e1b420fc5aeaae08fbb3ec4f5.PNG

 

 

To answer your question :

If you have URL Segment enabled on the template then you can do the following :

$segments = $input->urlSegments();
echo end($segments);

or

$segments = explode('/', parse_url($page->url, PHP_URL_PATH));
echo end($segments);

 

 

 

Edited by flydev
screenshot / format
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...