I have some forms where I want to have a text input line for each installed language (like in the category new/edit screen in the category module). Can this be achieved using pnform?
--
cyber_wolf
www.bkbsolutions.com - My Zikula module development site.
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- internetking created topic »password problem« 25. May
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
- mdee created topic »How to implement returnpage ?« 25. May
- nestormateo responded to »Fillters in Clip« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Language help in pnform (for .8)
-
- Rank: Developer
- Registered: Jun 03, 2002
- Last visit: Dec 21, 2009
- Posts: 284
-
- Rank: Software Foundation
- Registered: Sep 03, 2002
- Last visit: May 09, 2010
- Posts: 909
The easiest solution would be to integrate an input field for every language manually. As you don't install new langauges every day, that would be really simple. But if you intend to release you stuff, you should find a flexible solution. AFAIK there is a plugin in pnRender that produces a dropdown for all installed languages. Look into the code to find out how that one does the job and then copy that to your own plugin. I am sure there is only a pnModAPIFunc call that you can directly put into your template as well.
--
best regards from Kiel, sailing city
Steffen Voss
Member of the Zikula Steering Committee
Read The Zikulan's Blog "If you want people to RTFM, make a better FM!" -
- Rank: Developer
- Registered: Jun 03, 2002
- Last visit: Dec 21, 2009
- Posts: 284
I found a way to do what I wanted. May not be the best way, but it works.
In the newHandler's class initialize function I have...
Code
$sitelang = pnConfigGetVar('language');
$langs = LanguageUtil::getInstalledLanguages();
asort($langs);
$data = array();
foreach ($langs as $key=>$item) {
if (!isset($data[$key])) {
$data[$key] = array('language' => $key,
'title' => 'name_' . $key,
'value' => '',
'label' => ($key == $sitelang) ? 'Site ' . pnml('_bkbTableLanguage') . ' - ' . $item : pnml('_bkbTableLanguage') . ' - ' . $item);
}
}
$render->assign('data', $data2);
In the editHandler's initialize function...
Code
$data2 = array();
$sitelang = pnConfigGetVar('language');
$langs = LanguageUtil::getInstalledLanguages();
asort($langs);
foreach ($data as $item) {
$data2[$item['language']] = array('id' => $item['id'],
'language' => $item['language'],
'title' => 'name_' . $item['language'],
'value' => $item['name'],
'label' => $langs[$item['language']]);
}
if (pnConfigGetVar('multilingual') == 1) {
foreach ($langs as $key=>$item) {
if (!isset($data2[$key])) {
$data2[$key] = array('id' => $this->osid,
'language' => $key,
'title' => 'name_' . $key,
'value' => '',
'label' => $item);
}
}
} else {
$data2 = array($data2[$sitelang]);
}
In the Handler's class handle function I have...
Code
$nextid = (int)DBUtil::selectFieldMax('bkbmodule_status', 'id') + 1;
$records = array();
foreach ($Data as $key => $val) {
if ((!empty($val)) && (substr($key, 0, 4) == 'name')) {
$keylang = substr($key, 5);
if (!$keylang) {
$keylang = '';
}
$records[] = array('id' => $nextid,
'language' => $keylang,
'name' => $val);
}
}
And in the template.....
Code
<div class="bkbFormRow">
<b><!--[pnformlabel for=title text=_bkbStatus]--></b><b r />
<!--[foreach from=$data item=item]-->
<!--[pnformtextinput id=$item.title text=$item.value maxLength=32 width=30em]--> (<!--[pnml name="_bkbLanguage"]--> - <!--[$item.label]-->)<b r />
<!--[/foreach]-->
<b r />
</div>
edited by: cyber_wolf, Nov 28, 2007 - 09:18 PM
--
cyber_wolf
www.bkbsolutions.com - My Zikula module development site. -
- Rank: Softmore
- Registered: Jul 02, 2002
- Last visit: Oct 21, 2009
- Posts: 240
-
- Rank: Developer
- Registered: Jun 03, 2002
- Last visit: Dec 21, 2009
- Posts: 284
I'm trying to move these routines to a plugin now for easier usage and I'm having a problem in one spot that I cannot figure out.
If there is a validation error, what functions in the plugins are being called to redraw the screen? I'm sure there is a function that is being inherited that I need to overwrite; but I cannot seem to find it. When the screen is redrawn, all the input fields are gone.
--
cyber_wolf
www.bkbsolutions.com - My Zikula module development site. -
- Rank: Developer
- Registered: Jun 03, 2002
- Last visit: Dec 21, 2009
- Posts: 284
Figured out my problem. I was trying to save the data in the wrong function. The plugin works good now.
--
cyber_wolf
www.bkbsolutions.com - My Zikula module development site.
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
