Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Fields (and I18N)
hello again! Do any of you have an idea how to add the content of a custom field to another subpage with language support?

Currently, on the index page I have this (and it works without i18n language versions):

Code:
<? php get_custom_field ('section1'); ?>

On another page, I drag it through
PHP Code:
<? php getPageContent ('index', 'section1');?>


while when I connected the i18n language version, the translation does not change. Regardless of the language, it is always in that first language.

how to do it to detect what language we have and, if there is a second language (en), will replace it as in the example below.
PHP Code:
<? php getPageContent ('index_en', 'section1');?>


Or maybe there is some other way to do it? I am waiting for yours suggestions.
best regards.
Reply
Hi vixrealitum,

Yes that would be good to know. I have seen some code about language for this case somewhere.
I will have a look into it and post back.
Reply
I use one code per template for all languages.
Code:
<?php get_custom_field('pagetitle'); ?>
https://china-russia.ru/
https://crepemix.ru/
Reply
Oleg, but if you have a section with the same content on 10 pages, you have to fill each subpage with the same content 10 times. I am looking for a more compact solution to fill in one subpage and the rest will be drawn from it and will work with the option of language support.
Reply
(2020-11-06, 19:19:06)vixrealitum Wrote: Oleg, but if you have a section with the same content on 10 pages, you have to fill each subpage with the same content 10 times. I am looking for a more compact solution to fill in one subpage and the rest will be drawn from it and will work with the option of language support.

Understood, the difficulties of google translation. Smile
Reply
This code works.
Code:
<?php getPageField('index_en','pagetitle'); ?>
https://prnt.sc/vekfd8
https://prnt.sc/vekfw8
Reply
I found a solution that works on the principle I asked above.

This piece of code is enough..

PHP Code:
<?php if ($language == 'pl') { ?><?php getPageContent('index''section1');?><?php ?>
<?php 
if ($language == 'en') { ?><?php getPageContent('index_en''section1');?><?php ?>


The solution allows you to change the content in one place / section and then it can be repeatedly downloaded to different templates. It don't need to edit the same content multiple times on different tabs.

Custom Fields + I18N plugins are required for proper operation.
Reply
Hi vixrealitum,

Code:
<?php if ($language == 'pl') {php getPageContent ('index', 'section1');?>
<?php if ($language == 'en') {php getPageContent ('index_en', 'section1');?>

Nice,
Thanks for sharing this solution.
Reply
The "DY Website Custom Fields" plugin should also work similarly (uses 18n custom fields).

It is enough to create 2 fields for each language version and paste the code in a similar way:
PHP Code:
<?php if ($language == 'pl') { ?><?php get_website_custom_field('myname-customfield_pl'); ?><?php ?>
<?php 
if ($language == 'en') { ?><?php get_website_custom_field('myname-customfield_en'); ?><?php ?>

I hope that someone will find these solutions useful and make it easier to manage the website.
Reply
Why are shortcodes not working in fields?
Reply
Is it possible to modify plugin to use codemirror for WYSWIG Editor type field if WYSWIG Editor is disabled by default for whole system in settings?
Reply
Why does the use of html tags lead to such a result when setting fields in the I18N Special Pages plugin, 
[Image: tags1.jpg]

but to this in the I18N Custom Fields plugin?

[Image: tags2.jpg]

Is it possible to somehow fix the plugin I18N Custom Fields?
Reply
It looks like Special Pages is using "htmlspecialchars" for title/name fields, but Custom Fields is not.
Their setup is a bit different so, not sure how to implement that at the moment, will look at it closer when I get some time, unless anyone else has more experience with that type of thing.


GS Community Edition with php8.x compatibility, new features and much more!  Support Me


Reply
I added an image-field with the I18N Custom Fields plugin to my pages.

When click on the [browse] button, the file-manager pops-up, but the image-files are not shows up.

For testing: In the default editor, the tool [image] works the file-browser perfect.

When enable debug-mode, this error shows in the filebrowser:

[font=Arial, "Helvetica Neue", Helvetica, sans-serif]Fatal error[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php:105 Stack trace: #0 {main} thrown in [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]/domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif] on line [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]105[/font]

Someone have also this issue? How can i solve this?
Reply
(2023-02-01, 06:20:24)tuxy Wrote: I added an image-field with the I18N Custom Fields plugin to my pages.

When click on the [browse] button, the file-manager pops-up, but the image-files are not shows up.

For testing: In the default editor, the tool [image] works the file-browser perfect.

When enable debug-mode, this error shows in the filebrowser:

[font=Arial, "Helvetica Neue", Helvetica, sans-serif]Fatal error[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php:105 Stack trace: #0 {main} thrown in [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]/domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif] on line [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]105[/font]

Someone have also this issue? How can i solve this?

Found it!

Change the code in line 105 in the file ../plugins/i18n_customfields/browser/filebrowser.php :

change this code:

Code:
if (count($dirsSorted) != 0) {


with this code:

Code:
if (count((array)$dirsSorted) != 0) {
Reply
I guess that it's the same issue that we're having with News Manager's filebrowser (that is based on the one in I18N Custom Fields):
http://get-simple.info/forums/showthread...5#pid73355 (includes a suggested fix for GetSimple's subval_sort function, that is the source of the problem)
Reply
I18N Custom Fields:
* fixed php8 incompatibility of file and image browsers (page field, image field) - thanks to tuxy for pointing this out
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek,
With great pleasure, you do really good work, and super fast support.
Did a lot of tests, research and ask a lot of (stupid) questions in this active forum last month, and with the help from the active GS/GS CE-members, i make the disicion switch my blog https://gewoonsimpel.be to GS CE in the next days Smile
Reply
(2023-02-02, 06:37:31)tuxy Wrote: mvlcek,
With great pleasure, you do really good work, and super fast support.
Did a lot of tests, research and ask a lot of (stupid) questions in this active forum last month, and with the help from the active GS/GS CE-members, i make the disicion switch my blog https://gewoonsimpel.be to GS CE in the next days Smile

Its nice to see the forum coming back to life.
If you questions are getting answers that help, then they aren't any stupid questions.
Cant wait to see your GS version of the site!


GS Community Edition with php8.x compatibility, new features and much more!  Support Me


Reply
(2023-02-01, 06:20:24)tuxy Wrote: I added an image-field with the I18N Custom Fields plugin to my pages.

When click on the [browse] button, the file-manager pops-up, but the image-files are not shows up.

For testing: In the default editor, the tool [image] works the file-browser perfect.

When enable debug-mode, this error shows in the filebrowser:

[font=Arial, "Helvetica Neue", Helvetica, sans-serif]Fatal error[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php:105 Stack trace: #0 {main} thrown in [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]/domains/webkust.be/public_html/gscms/plugins/i18n_customfields/browser/filebrowser.php[/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif] on line [/font][font=Arial, "Helvetica Neue", Helvetica, sans-serif]105[/font]

Someone have also this issue? How can i solve this?

(2023-02-02, 06:44:39)islander Wrote:
(2023-02-02, 06:37:31)tuxy Wrote: mvlcek,
With great pleasure, you do really good work, and super fast support.
Did a lot of tests, research and ask a lot of (stupid) questions in this active forum last month, and with the help from the active GS/GS CE-members, i make the disicion switch my blog https://gewoonsimpel.be to GS CE in the next days Smile

Its nice to see the forum coming back to life.
If you questions are getting answers that help, then they aren't any stupid questions.
Cant wait to see your GS version of the site!

Yes, i learn a lot from the forum, reading about some things are solved, code-snippets, and so on. It's a paradise for devs/webdesigners and users ;-)

When the website is integrated with GS, i posted in the forum!

After see the possibilities and how flexible GS CE is with the help of the plugin repo, thinking also move a bigger project (https://dogvalley.be/) and try rebuild with GS CE :-)
Reply
(2012-04-20, 14:15:35)andyash Wrote:
mvlcek Wrote:global $SITEURL;
... echo substr($item->link,0,strlen($SITEURL)) == $SITEURL ? '_self' : '_blank'; ...
mvlcek Wrote:<a href="<?php echo htmlspecialchars($item->link); ?>" target="_<?php if($item->link!=='') { echo 'blank'; } else {echo 'self'; } ?>">

How and where do I put these two to achieve my target?

I need to know how to do this, as well.

...lee
Reply




Users browsing this thread: 6 Guest(s)