Jump to content

Default language cards output to multi-lang templates


jds43
 Share

Recommended Posts

Hello,

I have a multi-lang template (English and Spanish) where title, summary and body are translated. This template has many children in default (English) language and I need to output fields from these as cards on the Spanish page.

Is this even possible?

Link to comment
Share on other sites

I see that activating languages for this child template works for populating the cards, but I'll be deleting and re-importing a sizable list every few weeks and will need a way to activate the Spanish name for all. Should I not use the Import Pages by CSV module and opt for another solution?

Link to comment
Share on other sites

This will activate Spanish by template:

if($page->activate_spanish == 1) {
    $imported_producers = wire('pages')->find('template=producer');
    foreach ($imported_producers as $p) {
	    foreach (wire('languages') as $lang) {
		    if ($lang->isDefault()) continue;
		    $p->of(false);
		    $p->set("status{$lang->id}", 1);
		    $p->save();
	    }
    }
}

 

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...