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.
Options

Help with accessing database, vanilla 2 plugin

zodiacdmzodiacdm
edited June 2010 in Vanilla 2.0 - 2.8
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:


Motherboard:
<?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') ?>


Comments

  • Options
    You may feel free to create a profile and see the error for yourself ;)

    This only happens on the "edit" page of the Computer Profile.

    http://www.realgamersusepc.com
  • Options
    I think you use uncorrect tag for php form.
  • Options
    well these are the custom functions added into garden for easy setup, and are how most forms are displayed on the website. There is a declaration for "Dropdown", although the only use of forms I have seen were either "TextBox" or "RadioList" forms used elsewhere throughout the site.

    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 ^^
  • Options
    mdrmdr
    edited June 2010
    <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.
  • Options
    yeah, thanks for the tip, I had actually been suspecting what you just confirmed, that php is not responsible for any realtime content updates, only when it is called upon, and that is basically what javascript and ajax do, if I understand correctly.

    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
  • Options
    I think you should upload add plugins for
    php form .
  • Options
    Well, see, the thing is that I am trying to learn @Mark's codes, and functions that he worked so hard to design ^^

    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.
Sign In or Register to comment.