Jump to content

How can I hide a specific content-element for only one language?


Recommended Posts

Hi community,

I am using the "PageTable" Module (also called "ProFields: Page Table") and the built in "Language" Module (also called "Languages Support").


With the help of PageTable I was able to create several content elements which should usually be displayed in German(default language) and English.

However some Content Elements should only be shown in German and NOT in English.

Well sounds easy, right? Not so fast. I really love this CMS, but I have not found a solution for this problem yet.
As you can see in the screenshots attached I tried to uncheck the "active" Checkbox for the english language to completely hide the content element for english users.

However no matter what I do the german text shows on the english page.
If I leave the "content-should-not-be-shown-in-english"(see Screenshot Number 2) blank and save the page, the page will inherit the german page url "content-element-with-simple-text-which-should-only-be-shown-in-german".

My question therefore is:
How can I hide a specific content-element for only one language?

I´m using the latest processwire & module versions.

The code which I use to render the content elements looks like this:

//Info: contentelements is a field of type "ProFields: Page Table"
<?php foreach ($page->contentelements as $element):
    echo($element->render());
endforeach; ?>

filename: basic-page.php


I would really appreciate your help since I haven´t found a solution after reading through quite a lot of forum posts.

All the best,
Dani

Processwire_Post_2021_04_22_Pic1.png

Processwire_Post_2021_04_22_Pic2.png

Link to comment
Share on other sites

I don't know the PageTable field, but ...
there are settings which lets you decide what to do when a (language supported) field (or page?) is empty: don't show or inherit default. This is in PW since 2013 or version 2.4.

If it is explicitly with a single field that should be excluded if blank (and there is no setting what to do on empty languages), but the rest of the page should be rendered, at least one can define that in the rendering template file:
<pseudo-code> If language not is default AND field is empty: skip output </pseudo-code>

  • Like 1
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...