Hi,
I’m new to multiple languages on my site and am struggling with only returning the english translations for an array of listed pages. I’m using them as js and css hooks, so I’d like to only use the english translations. Here is what I currently have:
$navItems = $pages->listed()->pluck('slug');
I’ve tried:
$navItems = $pages->listed("en")->pluck('slug '));
and
$navItems = $pages->listed()->content("en"); // thought this might return the english translation
This has worked previously:
<a id="<?= 'nav-'. $p->slug("en")?>" // where $p is current page
And this doesn’t work anymore?
All the other trials don’t make sense, because listed()
doesn’t accept and argument, content()
is a page method, not a pages
method, and slug()
is not part of the content.
Ah, sorry I wasn’t clear, this works:
<a id="<?= 'nav-'. $p->slug("en")?>" // where $p is current page
but was hoping for a more convenient way to access the translations. Using the above, I would have loop through each page to create an array of en
page slugs(?):
$navItems = array();
foreach($pages->listed() as $p){
$navItems[] = $p->slug("en");
}
Is there a better way to do this?