Jump to content

page->name ist always the same


felted
 Share

Recommended Posts

Hello,

i get the content of a page with this code:

$datenschutz = $pages->get('/datenschutz/');

 

This are the settings in the BE:

page_name.jpg.a79a7248bc3a772ab6c244bbf0aa1a7c.jpg

 

But the output in DE and in EN is the same:
<?php echo $datenschutz_content->name; ?>

<div class="modal-modal mfp-hide" id="<?php echo $datenschutz->name; ?>">
  
<!-- Output DE: -->
<div class="modal-modal mfp-hide" id="datenschutz">  
<!-- Output EN: -->
<div class="modal-modal mfp-hide" id="datenschutz">    

 

How i get the page name für different languages?

Thanks, Detlef

Link to comment
Share on other sites

The problem ist, that the site is a onesiter.

The URL is always: http://xxx.biz/de/ for german and http://pw.xxx.biz/en/ for english.

Any content i get with:

$datenschutz_content = $pages->get('/datenschutz/');  
<?php echo $datenschutz_content->title; ?>

Output (title) for the URL http://xxx.biz/de/ is: datenschutz
Output (title) for the URL http://xxx.biz/en/ is: data protection

Everthing is fine.

But now i need the name of the page datenschutz.

If i unterstood correctly, the var $page contains only the content of the current page. So all the examples here are not working.

Example:

If the URL: http://xxx.biz/de/
I need the page name: datenschutz

and if the URL: http://xxx.biz/en/
i need the page name: data_protection (importend is the underscore)

 

I hope, it was a litte understandable ?

Thanks, Detlef

Link to comment
Share on other sites

Hello @felted,

the translated name should show up, if you are on the translated page:

$dataProtection = $pages->get("/datenschutz/");

// German on the default page
echo $dataProtection->name; // danteschutz

// English on the translated page
echo $dataProtection->name; // data_protection

If that doesn't work somehow, you could force this as mentioned with localName:

// German
echo $dataProection->localName("default"); // datenschutz

// English
echo $dataProtection->localName("english"); // data_protection

Or you could try Multi-Language Field Values:

$page->of(false); // turn off outputFormatting (if it's not already)

// German
echo $dataProtection->name->getLanguageValue("default"); // datenschutz

// German
echo $dataProtection->name->getLanguageValue("default"); // data_protection

Important is to pass the language you are looking for. ?

Regards, Andreas

  • Like 1
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...