Jump to content

Hide Content on Language


MateThemes
 Share

Recommended Posts

Hello!

I am fairly new to Processwire. In the past I used OctoberCMS for my project. But I have more and more multilanguage projects and OctoberCMS don't fit my needs anymore.

My first question to the community is, is it possible to hide/disable content based on the language. I mean, can a content editor say in German I want this content block and in Englisch I wanna hide this content block, based on the same layout?

Thanks for your answers.

Link to comment
Share on other sites

Welcome to the forum, @MateThemes !

As @Gideon So already pointed out, to accomplish this you will need to implement a condition on your template code depending on your business needs, but it can also be achieved without any custom code if it's just a matter of hiding a portion of a content from a page that has both languages.  

If you could explain a little bit more about what you want to accomplish, we can help. ?

 

Link to comment
Share on other sites

Languages are Pages in PW (like almost everything else). A user viewing any page in multilanguage environment has a language property attached (see here). So you can do it like this:

<?php

if($user->language->name != 'default') {
	echo 'Hello, multilanguage world!';
}

You can use $user->language->id if you want.

  • Like 3
Link to comment
Share on other sites

You have several options in the backend:


1.) Page based under Page > Settings
Enable or disable every non default language. Trying to access an inactive page will result in an 404

911768303_Bildschirmfoto2018-12-05um00_59_28.jpg.9f5ab001aa56c949e14b9b05ef54856b.jpg

 

2.) Template based under Template > Advanced (bottom)

540636816_Bildschirmfoto2018-12-05um01_02_54.jpg.007d611f9074bbf86b808ce5dc644364.jpg

 

3.) Field based under Edit Field > Details

2072876240_Bildschirmfoto2018-12-05um01_04_40.jpg.6a92592a5a89967efb23928067f31ce3.jpg

 

  • Like 2
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

×
×
  • Create New...