Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Fields (and I18N)
#1
As I have been notified that the custom fields of n00dles101's plugin are not correctly displayed when using the I18N plugin (i.e. the values of the default language are always shown), I have improved the I18N plugin to version 0.9.5 (http://get-simple.info/extend/plugin/i18n/69/). It will now also read all extra fields from the page (correct language version) and make them available via the functions get_custom_field($name) and return_custom_field($name).

Although this works, this is not very nice from an architectural point of view, e.g. page files are read by the I18N as well as the CustomFields plugins, values are available using getCustomField (default language) and get_custom_field (I18N, correct language), etc.

For these reasons I have improved the CustomFields plugin:
  • works more efficiently together with I18N plugin (although it also works stand-alone)
  • GUI to define the custom fields (no more fiddling with the XML)
  • new field types: check box and WYSIWYG textarea
  • Version 1.4+: automatically store creation date in page files
  • Version 1.5+: Enabled browsing in WYSIWYG editor for links and images
  • Version 1.5+: New image field allows browsing for local images
  • Version 1.5+: New link field allows browsing for local pages
  • Version 1.5+: Current user is automatically saved in field "user"

And - as it uses the same configuration file - it is compatible with the CustomFields plugin (although the CustomFields plugin won't display the new field types).

The new I18N Custom Fields plugin is available at http://get-simple.info/extend/plugin/i18...ields/100/.
If you use the I18N plugin (http://get-simple.info/extend/plugin/i18n/69/), make sure, it is at least version 0.9.5 (better: 1.1.2).

Installation

Unzip to the plugins directory, then define the custom fields in the administration GUI at Plugins/Configure Custom Fields.

To use browsing with link and image fields, turn on site wide cookies in gsconfig.php:
Code:
define('GSCOOKIEISSITEWIDE', TRUE);

Make sure the website base URL matches in the administration settings matches the actual URL.

Usage

Use any of the following functions in your template:
  • return_custom_field($name) returns the value of the custom field with the given name for the current page.
  • get_custom_field($name) outputs the value of the custom field with the given name for the current page.
  • get_page_creation_date($i = "l, F jS, Y - g:i A", $echo=true) (Version 1.4+) outputs the creation date of the page - if the CustomFields plugin in version 1.4+ was active at creation time or first update.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
mvlcek,

thanks a lot for your i18n-optimised custom fields plugin. I noticed in Extend that it's officially been tested against 2.03, but have you got it working with 3.0b as well?

I'm running a testsite with 3.0b and wanted to play around with a custom field to be put into the body class attribute for context-specific CSS styling. I (think) I followed your instructions successfully, yet nothing is output.

I defined a new field with the name of "site-language" and put the following function call into the body tag, analoguous to the get_page_slug(); call.

Code:
<body id="<?php get_page_slug(); ?>" class="<?php get_custom_field(site-language); ?>">
I then went to a page and entered some value into the new text field. The result is

Code:
<body id="some-page" class="">

If you need more info I'll gladly try to provide it.

Keep up the good work! Smile
Reply
#3
polyfragmented Wrote:I defined a new field with the name of "site-language" and put the following function call into the body tag, analoguous to the get_page_slug(); call.

Code:
<body id="<?php get_page_slug(); ?>" class="<?php get_custom_field(site-language); ?>">

It should work with 3.0b, but you definitely need quotes around the name (not sure why you don't get an error):
Code:
<?php get_custom_field("site-language"); ?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
I just tried it with quotes as well, same result.

I'll enable debugging, maybe that gives us a hint. Edit: no error whatsoever :/ Plus, the textfield on the edit page is not pre-filled with the default I set in the plugin config. Edit2: Prefill with new pages works.
Reply
#5
polyfragmented Wrote:I just tried it with quotes as well, same result.

I'll enable debugging, maybe that gives us a hint. Edit: no error whatsoever

Do you use the I18N CustomFields plugin together with the I18N plugin or standalone?
Do you see the entered value in the custom field, when you edit the page again?
If not, is the value stored in the page xml file?
If you are using the I18N plugin, are you displaying the correct language version of the page?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
mvlcek Wrote:Do you use the I18N CustomFields plugin together with the I18N plugin or standalone?
I use your custom fields plugin standalone.

mvlcek Wrote:Do you see the entered value in the custom field, when you edit the page again?
Yes, the value is persistent after I enter it in the page options. It is stored in the page XML file:

Code:
<site-language><![CDATA[de]]></site-language>

Calling it a day for today, will check back here tomorrow again. Thanks for investigating!
Reply
#7
Hey mvlcek.
I have been trying to get the i18n plugin and the i18customfields plugin to work for a while now. But i am still having problems. Really a noob here on the php end, so hard to debug not knowing what to look for. Anyway I am basing my testsite on GS 2.03.1, and using the latest i18n plugins. and i can create the customfields with no problem and also see that it is being save on the page. but nothing comes out on the site. i just empty. Using for example this line in my templates <?php get_custom_field($mainHeadline); ?> . Any idea what i could be doing wrong or what i could check somehow?
Reply
#8
linden Wrote:Hey mvlcek.
I have been trying to get the i18n plugin and the i18customfields plugin to work for a while now. But i am still having problems. Really a noob here on the php end, so hard to debug not knowing what to look for. Anyway I am basing my testsite on GS 2.03.1, and using the latest i18n plugins. and i can create the customfields with no problem and also see that it is being save on the page. but nothing comes out on the site. i just empty. Using for example this line in my templates <?php get_custom_field($mainHeadline); ?> . Any idea what i could be doing wrong or what i could check somehow?

If the name of the custom field is "mainHeadline" (without the quotes), you should use
Code:
<?php get_custom_field("mainHeadline"); ?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#9
mvlcek Wrote:
linden Wrote:Hey mvlcek.
I have been trying to get the i18n plugin and the i18customfields plugin to work for a while now. But i am still having problems. Really a noob here on the php end, so hard to debug not knowing what to look for. Anyway I am basing my testsite on GS 2.03.1, and using the latest i18n plugins. and i can create the customfields with no problem and also see that it is being save on the page. but nothing comes out on the site. i just empty. Using for example this line in my templates <?php get_custom_field($mainHeadline); ?> . Any idea what i could be doing wrong or what i could check somehow?

If the name of the custom field is "mainHeadline" (without the quotes), you should use
Code:
<?php get_custom_field("mainHeadline"); ?>

Of course. Thx Smile works fine now.
Reply
#10
Just tried renaming the custom field name to something without a dash, still the same result. :/ I'm stumped.
Reply
#11
I edited a post further up: Prefill with new pages works..

---

Would it be possible to generate a custom field which is shown n times? I'm thinking of links added to a page via text fields or lists. Maybe something similar to how you manage the dropdown field, but with (un)ordered lists?
Reply
#12
polyfragmented Wrote:Would it be possible to generate a custom field which is shown n times? I'm thinking of links added to a page via text fields or lists. Maybe something similar to how you manage the dropdown field, but with (un)ordered lists?

Do you mean a list like a dropdown, but multiple entries are selectable?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#13
mvlcek Wrote:Do you mean a list like a dropdown, but multiple entries are selectable?
Let my clarify, I am looking for a way to input, say, multiple links in a page's options which are then output on-page. In whatever form - (un)ordered lists, definition lists, whatever tickles the fancy.

After re-writing what I'd like to happen, I notice that my mentioning of dropdown fields is probably nonsensical. I can imagine the custom field being put in the page options n times if text fields are used so I can input a handful of links. Not looking for selecting from a pre-defined list by way of a dropdown.
Reply
#14
mvlcek Wrote:The I18N Custom Fields plugin is not yet (fully) compatible with GetSimple 3.0b:
  • fields are not shown correctly in the edit page view
  • WYSIWYG text area has the behavior like the content field in 2.03, thus no browse button.

I've noticed that there's a similar problem I had. You're not escaping commas when saving the file nor loading its content, thus every link pasted in text input won't be displayed, and will break the window after reloading page in edit mode.

Gotta look at mine own changes in Noodle's basic version, as I'd like to use your customfields remake, but it needs fixes.


edit:
k, stripslashes($value) and turning off magic quotes did the thing
Addons: blue business theme, Online Visitors, Notepad
Reply
#15
yojoe Wrote:I've noticed that there's a similar problem I had. You're not escaping commas when saving the file nor loading its content, thus every link pasted in text input won't be displayed, and will break the window after reloading page in edit mode.

This should be fixed with version 1.3.
And the texts have been moved to language files - using my Translate plugin has sped this up for sure ;-)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#16
Version 1.4:
  • correctly displays custom fields in page view of GetSimple 3.0
  • automatically saves creation date of page - retrieve it with function get_page_creation_date($format = "l, F jS, Y - g:i A", $echo=true).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#17
Just installed 1.4 into GS 3.0 and, after filling in a new custom field config and hitting save, got the following:

Code:
Warning: copy(/www/htdocs/foo/testlab/data/other/customfields.xml) [function.copy]: failed to open stream: No such file or directory in /www/htdocs/foo/testlab/plugins/i18n_customfields/configure.php on line 14

The custom field does not get saved.

What gives?
Reply
#18
polyfragmented Wrote:The custom field does not get saved.

Undo preparation was preventing save, if there was no old customfields.xml.
Fixed in version 1.4.1.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#19
Loving this plugin. And wondering if there would be a way to "link" certain custom fields to a specific template. like for instance if i have 2 pages with different templates. and i would have different informations on them. I would like to have a certain set of custom fields on startpage for example with banner areas or different columns with information. and the standard page would just have content and maybe a sidebar. So different customfields depending on what template i am using. That would make me a really happy man Smile

Might want to add that i would want the certain customfields showing on only that perticular page that i would specify. Otherwise i know i could t it as it is already. But i dont want all customfields showing on all pages. Hope you understand what i mean.
Reply
#20
Hi,
I'm sorry for my English
The plugin works fine, but there is a slight problem.
When I try to insert an image in the main content editor a button "Browse server" apears in the image properties window, but it doesn't in the custom field editor
Is there any chance to fix this?
Reply
#21
ragou Wrote:When I try to insert an image in the main content editor a button "Browse server" apears in the image properties window, but it doesn't in the custom field editor
Is there any chance to fix this?

It's on my to do list.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#22
In the page options right above the "Custom Fields" headline

Quote:Notice: Trying to get property of non-object in /www/htdocs/foo/testlab/plugins/i18n_customfields/edit.php on line 11

Does not seem to affect page saving at all.
Reply
#23
Version 1.5 is available:
  • Enabled browsing in WYSIWYG editor for links and images (not supported in GetSimple 2.03)
  • New field type "image": like text field, but allows browsing for local images (not supported in GetSimple 2.03)
  • New field type "link": like text field, but allows browsing for local pages (not supported in GetSimple 2.03)
  • Current user is automatically saved in field "user"

@linden: showing fields depending on a template is much too complex to implement (showing/hiding fields, when template is changed, templates are dependent on current theme, ...)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#24
mvlcek Wrote:Version 1.5 is available:
  • Enabled browsing in WYSIWYG editor for links and images (not supported in GetSimple 2.03)
  • New field type "image": like text field, but allows browsing for local images (not supported in GetSimple 2.03)
  • New field type "link": like text field, but allows browsing for local pages (not supported in GetSimple 2.03)
  • Current user is automatically saved in field "user"

@linden: showing fields depending on a template is much too complex to implement (showing/hiding fields, when template is changed, templates are dependent on current theme, ...)

Ok, yeah i just work at front-end so i dont know what is possible. just a thought. Smile Thx for a super plugin anyway. And just got better with link and image support.
Reply
#25
Thanks again for updating this plugin Smile

When I click on the 'Browse' button given by the functionality of the two new fields, a page does pop up, but it remains blank. Am I doing something wrong?
Reply




Users browsing this thread: 5 Guest(s)