Jump to content

how to get last url path


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>";}
								} ?>


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


select turkish language


it must be 



if i use


instead of


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


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




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);


$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

  • Recently Browsing   0 members

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