Jump to content

Active field for default language


Friedrich
 Share

Recommended Posts

Hello everybody! I started using Proccesswire and I am really surprised how developer-friendly and easy-to-use a CMS/CMF can be at the same time. Really nice!!!

But I encountered my first problem. I develop a multilanguage website and there should be a page for news articles which are not translated. Every language should have their own news-articles. Is it possible to have an "active" checkbox for the default language? How do you manage pages which should be only available to the not-default language?

Thanks for you help.

PS: Forgive me my bad english and "HALLO" to all germans here :)

Link to comment
Share on other sites

Hi Friedrich, welcome to the forum!

This can be done in several ways. and depends a lot on some factors. Will there be any news in several languages, or they will always be each one in it's own language?

If they will be sometimes in only one language, but other times in more, I would ignore those active checkboxes in the settings, and create my own checkboxes in the main edit page. For this, simply create a page field type, choose checkboxes as the input field type and choose the languages page as parent. Add it to your articles template, and you will have the three languages, with a checkbox each. Then, on your template you can do something like this to get the news:

//let's say the new field is called "active"

$lang = $user->language; //the language being viewed in the browser

$news = $pages->find("parent=news, active={$lang}"); we're getting all the news where this language is selected

foreach($news as $article) {
   // echo things
}

If each article will be only in one language you can simply create a news page for each languages and create the articles for that language as children with non multi language fields. Then show one news parent or the other depending on the language. This solution is probably simpler for the editor, but probably a little more difficult to set up.

  • Like 1
Link to comment
Share on other sites

Okay thanks, this helps me a lot. And how can I create a page with just one laguage filled? When I create a page and I fill the title & url fields only for the main language, it is valid.

But if I do the same and fill the fields only for the second language I get an error message because the title field and the url field in the default language is required. How can I avoid this?

Link to comment
Share on other sites

Those pages would be language agnostic, so you (your editor) would have to fill the default language name and title, independently of what language it is, and ignore the others. I'm not sure if there is a way to avoid showing the language names based on the template and can't check right now.

EDIT: for the Title you can create a non-multilanguage title and use tat one on this template, my doubt is with the page name.

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