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?


Share this post

Link to post
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

Share this post

Link to post
Share on other sites

The url segment l try to get is on the sub category of treatments page so url segment is for the present page i think.

I get the url of treatment url or title of treament bit i cannot get the last segment of treatment url

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...