Thread tagged as: Question, Configuration

perch_pages_navigation for multilingual

I am running a multilingual site using a region for each language (strategy two).

I have second level subpages, and I would like to display page navigation on both languages. Actually is only displaying Navigation text on page details. How can I make perch_pages_navigation gives me actual language?

Raul Serrano

Raul Serrano 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where is the string you want to output stored, and how and you attempting to use it?

Main page everthing OK: url: Innovation/index.php regions: Innovation-en / Innovation-es

<?php perch_content('Innovation-'.$lang); ?>

Subpages: - url: innovation/bim.php (regions: BIM-en / BIM-es) - url: innovation/green-concience.php (regions: Green-Concience-en / Green-Concience-es) - url: innovation/energy-efficiency.php (regions: Energy-Efficiency-en / Energy-Efficiency-es)

it uses perch_pages_navigation to display navigation between subpages, working ok with main language (english)

<div class="container">
    <?php perch_pages_navigation(array(  
                    'from-path' => '/innovation/',  
                    'levels'    => 2,
                    'hide-extensions'      => false,));  
        <div class="folder"><a href="/innovation/">Innovation</a> / </div>
        <?php perch_content('Subpage-'.$lang); ?>

**I would like to display navigation lists on spanish when `$lang = 'es'`` **

Navigation item template:

    <ul class="page-nav">
            <a<perch:if exists="current_page"> class="current"</perch:if><perch:if exists="ancestor_page"> class="ancestor"</perch:if> href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>   
            <perch:pages id="subitems" encode="false" />

Maybe using some other tag instead of <perch:pages id="pageNavText" />will take region depending on language?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, add the translated title as a page attribute. You can display those in navigation templates.

I don't get how to do that Drew...

Should I replace <perch:pages id="pageNavText" /> for <perch:content type="text" id="subpage_heading" label="Subpage Heading" title="true" required="true" /> from subpage template?

If I could have two fields for Navigation Text on page details, one for each language, I could pass $lang variable and make something like this on item.html...?

<perch:if id="lang" value="en"><perch:pages id="pageNavText-en" /></perch:if>
<perch:if id="lang" value="es"><perch:pages id="pageNavText-es" /></perch:if>

hmmm... no idea

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's the general idea.

But how I could create a second navigation text input? In witch template should I create it?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you enable debug you can see which templates are currently being used.

Looking at debug, it takes me to perch/templates/pages/attributes/default.hmtl. I can see description, keywords and some checkboxes, but there is no navigation text... Could you help me Rachel?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you added the new field you want? It won't be there until you add it.

I've finally make a raw navigation... thanks anyway, this aspect is not so clear...

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's really not as complicated as you're making it.

  1. Add the translation as a page attribute
  2. Use the page attribute in the navigation template.