Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Help with accessing database, vanilla 2 plugin
zodiacdm
✭
I am only a novice coder, and have taken what I could learn from the other plugins and the base applications, and have begun work on my own plugins.
Starting with a Computer profile for each user, based on @piggy's My Profile. I got a very basic version of my plugin working by adding extra fields to his plugin, however I am trying to create arrays for users to pick from a dropdown, and keep getting a "Trying to get property of non-object" Error message when I try to access the database the way I thought propper.
I am sure that I would eventually figure this out on my own, however, I have been working on this for a few days now and would appreciate a point in the right direction.
I am sure any experienced coder could quickly point out my mistake. Thanks guys.
My method:
<?php
echo $this->Form->DropDown('MotherboardMan', $this->PCProfile->MotherboardMan, array('default' => 'Other'));
if ($this->PCProfile->MotherboardMan === 'Other') {
echo $this->Form->TextBox('MotherboardManCus'); } ?>
<?php
echo $this->Form->TextBox('MotherboardMod') ?>
<?php
echo $this->Form->TextBox('MotherboardDet') ?>
Starting with a Computer profile for each user, based on @piggy's My Profile. I got a very basic version of my plugin working by adding extra fields to his plugin, however I am trying to create arrays for users to pick from a dropdown, and keep getting a "Trying to get property of non-object" Error message when I try to access the database the way I thought propper.
I am sure that I would eventually figure this out on my own, however, I have been working on this for a few days now and would appreciate a point in the right direction.
I am sure any experienced coder could quickly point out my mistake. Thanks guys.
My method:
<?php
echo $this->Form->DropDown('MotherboardMan', $this->PCProfile->MotherboardMan, array('default' => 'Other'));
if ($this->PCProfile->MotherboardMan === 'Other') {
echo $this->Form->TextBox('MotherboardManCus'); } ?>
<?php
echo $this->Form->TextBox('MotherboardMod') ?>
<?php
echo $this->Form->TextBox('MotherboardDet') ?>
0
Comments
This only happens on the "edit" page of the Computer Profile.
http://www.realgamersusepc.com
My main issue is trying to make too big of a step without knowing what I am doing. I essentially wanted to have several dropdown menus for different computer parts vendors, in which the selection would display a logo in the view panel. If the dropdown was selected "Other", a textbox form would appear on the edit, and replace the logo on the view page. Get what I mean? :P ^^
<script language="javascript">function OtherCheck(element){ if(element.selectedIndex = "Other") {document.getElementById(MotherboardMod).style.display = 'inline'; } else document.getElementById(MotherboardMod).style.display = 'none' }</script>
Messy? Sure probably but it'd most likely work.
Then all you'd have to do is a quick CSS display:none; on #MotherboardMod and slap an OnChange inside of the MotherboardMan selectbox.
PHP: Hypertext Preprocessor. . . "PREprocessor", it's not dynamic, it's serverside and it does all of it's magic before the page loads.
EDIT:
You're also not showing us where you're accessing the database. . . we can't find an error unless you show the part of the code you need help with.
Think my mistake is in the database... I removed all the "if"'s and left just a few menus, which I changed to exactly how the "male"/"female" option is in the main profile, but I am still getting a bizarre error.
Now it is saying something about not being able to find the view location, although the forms and database are the only thing I modified, and and am not sure how this is at all related...
here is how I added the columns with the options that I would like to use for the menus. This should essentially be the same as how the "Gender" column is set up, although I cannot for the life of me find the code where he first created it, probably somewhere in the setup folder...
->Column('ProcessorMan', array('A','I','X'), FALSE, 'X')
then in the edit:
$this->ProcessorManOptions = array(
'A' => Gdn::Translate('AMD'),
'I' => Gdn::Translate('Intel'),
'X' => Gdn::Translate('Not Sure'),
);
echo $this->Form->Label('Manufacturer', 'Manufacturer');
echo $this->Form->RadioList('ProcessorMan', $this->ProcessorManOptions, array('default' => 'X')); ?>
I took a few days to switch from a windows server to linux, but now am back on this project, although it's 8 A.M. and I haven't slept yet so... XD
php form .
Even though I still have very little php knowledge, I can see what a great idea @Mark had in this program, making things as simple as possible to create additions, although the trick is learning all of his pre-declared functions and the configuration that goes with each. This proves especially difficult for someone who does not have the basics of php down...
Ah, well, I suppose I can use standard php to create a working form for the plugin, then modify it as necessary to fit the garden system.