Closed TrueHatori closed 5 years ago
Maybe my OweMe plugin can help (see my GitHub repositories). It's somewhat outdated but the basics should be explained clearly.
Thank you very much, I'll take a look at it right after breakfast.
Funny, I had the same questions some years ago... and yes, OweMe plugin was the only understandable source at that time. Then I found that if I use plugin builder and select dropdown type, it will do most of it itself.
PS. Plugins by lonalore are next level for studying and next is vstore.
@Moc you should replace fetch() with retrieve() nowadays. And add optArray key there. To deptors dropdown I mean.
I'll take a look but fetch should still work although retrieve is recommended.
@Moc I know, but this is really the example for others. It was only suggestion.
Thanks again, now things are going well. For now I have one more question: How do I get a multiple choice in the dropdown lists? I would prefer checkboxes, but since I'm the only one who will fill out the form, it does not matter.
/Edit
What I've just seen: The items in the dropdown lists are sorted by id. Is it possible to sort them alphabetically by content? With 40+ elements that will quickly get confusing. I tried that, but it does not work:
if($sql->select('kraeuterkunde_heilwirkung', '*', '', 'kk_HWirkung_Wirkung'))
Sorting has done. I've used a $ sql->gen instead of $ sql->select, which does exactly what it should. Remains the problem with the multiple selection, I have no idea.
look at newspost.php and selecting template field during edit news. Or look for word 'multi' in admin_ui handler. I think it's just a parameter for checkboxes... If you need this for user classes, there is field type for this already.
Thanks, I looked this, but I did not understand it :( Like the preferences in the newspost.php I would like, but I can not get it. What I have now: In the protected $fields
'kk_HWirkung_ID_fremd' => array (
'title' => 'Wirkungsbereiche',
'type' => 'dropdown',
'data' => 'str',
'width' => 'auto',
'inline' => false,
'validate' => true,
'class' => 'left',
'thclass' => 'left',
),
Then in the init()
$this->kk_HWirkung_ID_fremd[0] = 'Bitte wählen';
if($sql->gen("SELECT * FROM #kraeuterkunde_heilwirkung ORDER BY kk_HWirkung_Wirkung ASC"))
{
while($row = $sql->fetch())
{
$this->kk_HWirkung_ID_fremd[$row['kk_HWirkung_ID']] = $row['kk_HWirkung_Wirkung'];
}
}
$this->fields['kk_HWirkung_ID_fremd']['writeParms'] = $this->kk_HWirkung_ID_fremd;
So I have the dropdown list, it is also neatly sorted. It remains my problem with the multiple choice, I have no more ideas.
sorry, the field name is news_render_type.
Check this: https://github.com/e107inc/e107/issues/2769
here is now this:
'news_render_type' => array('title' => LAN_LOCATION, 'type' => 'dropdown', 'data'=>'safestr', 'tab'=>2, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true),
What you don't understand?
I tried, after that nothing went, so I undid it.
I think I solved my problem for the time. In the manuel is "checkbox", but it must be called "checkboxes". In the newspost.php the options are in readParms, I have to write it in writeParms. It works this way now:
'kk_Anwendung_ID_fremd' => array (
'title' => 'Anwendung bei',
'type' => 'checkboxes',
'data' => 'str',
'width' => 'auto',
'inline' => false,
'readParms' => '',
'writeParms' => array('type' => 'checkboxes'),
'validate' => true,
'class' => 'left',
'thclass' => 'left',
'toggle' => 'e-multiselect',
),
if($sql->select('kraeuterkunde_heilwirkung'))
{
while($row = $sql->fetch())
{
$wirkID = $row['kk_HWirkung_ID'];
$this->wirkung[$wirkID] = $row['kk_HWirkung_Wirkung'];
}
}
asort($this->wirkung);
$this->fields['kk_HWirkung_ID_fremd']['writeParms']['optArray'] = $this->wirkung;
One more question: Is there an option for asort () that ignores upper and lower case? I did not find anything in the PHP manual.
No, it does not work. The script does exactly what it should, but not what I want. The source of the site is now something like this:
<label class='checkbox'><input type='checkbox' name=**'kk_HWirkung_ID_fremd[22]' value='1'** id='kk-hwirkung-id-fremd-22-1' />Immunsystem stärkend</label>
It should look like this:
<label class='checkbox'><input type='checkbox' name=**'kk_HWirkung_ID_fremd[]' value='22'** id='kk-hwirkung-id-fremd-22-1' />Immunsystem stärkend</label>
Something is missing there and I can not get it. In all examples with checkboxes, the arrays are filled manually, not from a database. I think I give up for now and do something else.
You always can use type method and write it yourself.
but check this too: https://github.com/e107inc/e107/issues/1261 I know that question is about select, but keys should work the same way
In the newspost.php the options are in readParms, I have to write it in writeParms.
I can see it in edit mode:
And code looks like your needed code.
This is what you are missing with this news example:
$this->fields['news_template']['writeParms']['optArray'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox");
$this->fields['news_template']['writeParms']['multiple'] = 1;
No, that's not what I need, this ist dropdown, I need checkboxes. I need a name name for the array like checkbox[], a value, and a label. In the moment Value is where the name belongs - looks like so:
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[22]' value='1' id='kk-hwirkung-id-fremd-22-1' />Immunsystem stärkend</label>
In ALL values is '1'. I need it so:
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[]' value='22' id='kk-hwirkung-id-fremd-22-1' />Immunsystem stärkend</label>
But something else. I have a table with two dates, beginning and end. In the admin section sorts itself by $ ListOrder. But how can I sort those in the front page after the start? Already sorting within the query works only in $ sql->gen, but that can not be the point of the matter. With all these classes is great, but if the documentation is barely available, it is very difficult. I understand that programmers do not like to write manuals, but a little bit of what and then how to understand it would be nice. At the moment it looks like this: http://www.ninja4ever.de/e107_plugins/eventcalender/eventcalender.php But that can not be the case, nobody will find anything, it has to be sorted in ascending order by date.
I can stand the frustration for a few more days, then I'll get an old version 1.x, with this I can do it all.
@TrueHatori you can use a similar way as in v1 in version 2. You don't need to use admin_ui or OPP, it's on you.
Or upload your plugin to a repository if you want this type of help. But I thought I saw plugin with name...
Why should I work with outdated code in a CMS that offers such nice possibilities? I solved the last problem by not working on the output side with the possibilities offered. But I can not use shortcodes and templates with that. That can not be the point of the matter. What I do not understand at all: There is the option ORDER BY in MySQL for the SELECT-Statement, why can not I use it? That makes everything unnecessarily complicated.
I give up, I can not do that. Now I have to use a CMS which offers great possibilities but must use old code. On a v1.x I can not go, on my server runs PHP 7. Without a detailed manual, the system is not usable for an advanced amateur as a programmer. I have no time (and no desire) to study thousands of lines of program code to make a little progress. There are too many questions left. Small applications are possible, but already something like above fails.
What do you have to write in here and what not? - protected $fieldpref = array();
What belongs here? - protected $prefs = array();
How do you formulate parms? These are all questions that can only be answered by chance and much time to read code, if at all.
The v1.x was available for anyone with intermediate knowledge, the v2.x seems to be only for absolute professionals. No detailed manual = very large frustration factor.
What do you have to write in here and what not? - protected $fieldpref = array();
Did you check _blank plugin as the documented example? everything is written there. A: //required - default column user prefs
What belongs here? - protected $prefs = array();
A: // optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
I understand your frustration, I was there some years ago and I am still with anything new I try. Maybe if that time were more people who believed in the new version and helped, then everything would be easier now. Because then you would have these questions together with others.
I offered you help if you share your code. Or you can ask the real questions on the forum on my support site so I could improve our Knowledgebase. Sorry, but I will not go back in time and answer here really basic questions (those last 2 ones, that one about checkboxes wasn't).
Where is the "basic question" with my question? I know how to write checkboxes, only the system does not know or I do not explain it properly. I have already posted the code 2x, but for you also a third time.
In Protected fields:
'kk_HWirkung_ID_fremd' => array (
'title' => 'Wirkungsbereiche',
'type' => 'checkboxes',
'data' => 'safestr',
'width' => 'auto',
'inline' => true,
'readParms' => array('type' => 'checkboxes'),
'writeParms' => array('type' => 'checkboxes'),
'validate' => true,
'class' => 'left',
'thclass' => 'left',
'nosort' => false,
'batch' => true,
'filter' => true,
'toggle' => 'e-multiselect',
),
In init():
$sql = e107::getDb();
// Checkboxen erstellen fuer Heilwirkung
$entries = $sql->select('kraeuterkunde_heilwirkung');
if($entries)
{
while($row = $sql->fetch())
{
$wirkID = $row['kk_HWirkung_ID'];
$wirk_wirk = $row['kk_HWirkung_Wirkung'];
$this->wirkung[$wirkID] = $wirk_wirk;
}
}
asort($wirkung, SORT_STRING | SORT_FLAG_CASE | SORT_NATURAL);
var_dump($this->wirkung);
$this->fields['kk_HWirkung_ID_fremd']['writeParms']['optArray'] = $this->wirkung;
$this->fields['kk_HWirkung_ID_fremd']['writeParms']['multiple'] = 1;
The var_dump:
array(23) { [2]=> string(14) "adstringierend" [1]=> string(14) "antibakteriell" [3]=> string(16) "auswurffördernd" [20]=> string(13) "blutreinigend" [10]=> string(25) "Blutzuckerspiegel senkend" [13]=> string(22) "durchblutungsfördernd" [14]=> string(19) "entzündungshemmend" [15]=> string(10) "erweichend" [4]=> string(12) "harntreibend" [16]=> string(14) "hustenstillend" [22]=> string(21) "Immunsystem stärkend" [5]=> string(13) "krampflösend" [21]=> string(19) "Kreislauf stärkend" [17]=> string(8) "lindernd" [6]=> string(26) "Menstruation abschwächend" [23]=> string(23) "Milchsekretion anregend" [18]=> string(12) "reizmildernd" [7]=> string(14) "schleimlösend" [8]=> string(15) "schmerzstillend" [9]=> string(16) "schweisstreibend" [11]=> string(11) "tonisierend" [12]=> string(8) "wärmend" [19]=> string(11) "wundheilend" }
The Source from the side:
<tr><td><span>Wirkungsbereiche</span></td>
<td><div class='checkboxes' style='display:inline-block'>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[2]' value='1' id='kk-hwirkung-id-fremd-2-1' />adstringierend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[1]' value='1' id='kk-hwirkung-id-fremd-1-1' />antibakteriell</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[3]' value='1' id='kk-hwirkung-id-fremd-3-1' />auswurffördernd</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[20]' value='1' id='kk-hwirkung-id-fremd-20-1' />blutreinigend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[10]' value='1' id='kk-hwirkung-id-fremd-10-1' />Blutzuckerspiegel senkend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[13]' value='1' id='kk-hwirkung-id-fremd-13-1' />durchblutungsfördernd</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[14]' value='1' id='kk-hwirkung-id-fremd-14-1' />entzündungshemmend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[15]' value='1' id='kk-hwirkung-id-fremd-15-1' />erweichend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[4]' value='1' id='kk-hwirkung-id-fremd-4-1' />harntreibend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[16]' value='1' id='kk-hwirkung-id-fremd-16-1' />hustenstillend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[22]' value='1' id='kk-hwirkung-id-fremd-22-1' />Immunsystem stärkend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[5]' value='1' id='kk-hwirkung-id-fremd-5-1' />krampflösend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[21]' value='1' id='kk-hwirkung-id-fremd-21-1' />Kreislauf stärkend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[17]' value='1' id='kk-hwirkung-id-fremd-17-1' />lindernd</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[6]' value='1' id='kk-hwirkung-id-fremd-6-1' />Menstruation abschwächend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[23]' value='1' id='kk-hwirkung-id-fremd-23-1' />Milchsekretion anregend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[18]' value='1' id='kk-hwirkung-id-fremd-18-1' />reizmildernd</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[7]' value='1' id='kk-hwirkung-id-fremd-7-1' />schleimlösend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[8]' value='1' id='kk-hwirkung-id-fremd-8-1' />schmerzstillend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[9]' value='1' id='kk-hwirkung-id-fremd-9-1' />schweisstreibend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[11]' value='1' id='kk-hwirkung-id-fremd-11-1' />tonisierend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[12]' value='1' id='kk-hwirkung-id-fremd-12-1' />wärmend</label>
<label class='checkbox'><input type='checkbox' name='kk_HWirkung_ID_fremd[19]' value='1' id='kk-hwirkung-id-fremd-19-1' />wundheilend</label></div>
</td></tr>
In ALL values is "1", this is not right. The correct value is written in the name. What is there, must be in the value.
An example like the _blank plugin is helpful, but it does not replace a complete manual. Something like that did not exist in the v1.x, but that was not so bad, most of it was basic knowledge. That is not enough for the v2.x.
Last ones are basic. Sorry if I understood you incorrectly.
What do you have to write in here and what not? - protected $fieldpref = array();
What belongs here? - protected $prefs = array();
I don't need your code here, it will not work for me. I wanted you to post your plugin in your repository so I can install it and try. The problem can be somewhere else because I am sure I gave you the correct answer before.
I was just trying to upload the files, it does not work. I have the problem here with everything, I can not upload screenshots either. It always comes only here: "Something went really wrong, and we can't process that file".
You can't insert files here. This is working example:
'blank_compatibility'
=> array(
'title' => "Checkbox check",
'type' => 'dropdown',
'data'=>'str',
'inline'=>true,
'readParms'=>array('type'=>'checkboxes'),
'writeParms'=>array('multiple'=>'1', 'optArray' => array('0'=>'first option', '1' => 'second option')),
'width' => 'auto',
'thclass' => 'left',
'class' => 'left',
'nosort' => false,
),
output code
I wrote you this solution some posts above...
With Chrome you can post images directly here, not with Firefox.
Somewhere is article how to work with github and e107. You need to create a repository under your account and upload files there. Yes, again, I had to learn this too, I am not developer, just basic Nuke user. I use Github for Windows and it does all work for me with github. None developer stuff.
Fine thing your example, but goes past the topic :( I have an array, this is in the init() generated, but the values are not correctly assigned. I have the values in the database, there they are read and in the array written ... and then? In ALL Values a 1 ... And you have a dropdown list, I'm talking about checkboxes.
I have created a repository. I should then select my files and upload ... and then comes the error message, it will not work. I'll see if I can find another way. Chrome does not come to my computer, so Google knows enough about me.
Okay, I'm going to a seminar tomorrow, maybe I'll get it out of my head and think Monday again ;)
Do you see screenshots? What is it if not checkboxes?
dropdown means that you click and some list is opened...
$this->fields['your fields']['writeParms']['optArray'] = - just put your array here in init() like you have here: $this->fields['kk_HWirkung_ID_fremd']['writeParms']['optArray'] = $this->wirkung;
You don't need next list in read mode.
xxx
Just don't think too much - they are normal arrays, normal php, admin UI just saves your time with coding, nothing more. It works with arrays.
That brings nothing, nothing at all. What you say, I did the same and ... in ALL Values a 1. I'll let that be. For a week I try that now and it does not work. In time I would have done it on the old method for a long time and also all the database entries in it. I wanted to do it with the new possibilities, but if I need it longer than with the old method, then I do not care about new possibilities. That's a waste of time and I do not have that much anymore, I'm 61 now.
I do not understand this new system properly. I have three tables, from two tables I need the ID and the text str (dropdown field or I would rather checkboxes) in the form for the big main table. After I have the admin_gallery.php, the image.php and also the admin_config.php from the _blank_plugin studied, I still do not understand it. Something is written in the init(), sometimes in the form_ui, I do not recognize the principle. Can someone tell me where to find a simple example of dropdown or checkboxes whose values come from a second table? This is not a problem in "normal" PHP, but I do not really understand OOP yet.