Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello, I'm wondering if it's possible to output just a file name like "contact.php" or "home.php" via couch? I would find it useful to build links to files which have the same name but are located in different folders.

I found the following php snippet, but fore some reason it was not working in the link

Code: Select all
<?php
$currentFile = $_SERVER["PHP_SELF"];
$parts = Explode('/', $currentFile);
echo $parts[count($parts) - 1];
?>
found a solution myself. I added a variable and the output of these <cms:show pagename/> is working fine also in links.

Code: Select all
<cms:set pagename ="<?php $currentFile = $_SERVER["PHP_SELF"]; $parts = Explode('/', $currentFile); echo $parts[count($parts) - 1];?>" 'global'/>
Glad you found the solution :)
You mentioned:
..useful to build links to files which have the same name but are located in different folders

If the files happen to be Couch templates (as it appears), the following would have also outputted the link
Code: Select all
<cms:link masterpage=k_template_name />

Or are you trying to achieve something else? Could you please let me know?
Thanks.
hi,

thanks for your answer. Your code outputs the complete url of the page. So in my case it would look like this:

www.domain.com/de/home.php

I was searching for a tag which only output "home.php". It's again for the multilingual page. There are flags to choose your preferred language which should link to the same page in the other folder. The file names in the language folders are the same. So my solution to build the link looks now like this:

Code: Select all
<a href="<cms:show k_site_link />de/<cms:show pagename />">img....</a> 
<a href="<cms:show k_site_link />eng/<cms:show pagename />">img....</a>   
OK. That explains it :)
Thank you.
5 posts Page 1 of 1