Fork me on GitHub

Watch

GitHub Core

Show your support for Zikula! Sign up at Github account and watch the Core project!




GitHub Modules

Forum Activity

Forum feed

» Visit forum | » View latest posts

basic-ish :)  Bottom

  • ok this is basic .. but

    (note all the examples here are not exactly how i will have them because they are taken directly from other modules)


    Code

    $row[] = $output->FormSelectMultiple('pollrecurring',array(
                                                       array('id' => 0,
                                                         'name' => 'No'),
                                                       array('id' => 1,
                                                         'name' => 'Yes')),


    ok well just to make sure i have anyidea what im talking about what does the 'pollrecurring' meen? or rather what is it?


    so what im trying to do is .. just have a yes or no option .. but of course its gonan have to know wat you're setting the value of 1 or 0 (yes or no) too

    is it setting the value of 0 or 1 to 'pollrecurring' ??

    if so (im really beginner) will i have to incorperate that in the init file?



    one last question .. how do i call upon that valu late .. jsut liek all i want to say is .. place the value of 'pollrecurring' (if thats right) here ...

    so if i wanted to incorperate this in an if statment would it be liek this


    Code

    if ($item['pollrecurring'] == 0) {  }


    orr.. is that $item evin supposed to be there :D
  • The form will go to another PHP function, inside that function you would call

    Code

    $pollrecurring = pnVarCleanFromInput('pollrecurring');

    and then reference it by $pollrecurring. Basically, you are naming the select statement pollrecurring, and it will be passed as a post variable (or a get variable, but the default is post) to the next function (named when you start the form). The equivalent HTML statement for that FormSelectMultiple would be:

    Code

    <select name="pollrecurring">
    <option value=0>No
    <option value=1>Yes
    </select>


    If you look in includes\pnhtml.php, all of the HTML functions are documented in the code. I have found most of them to be documented fairly well.
  • That code looks kind of familiar, looks like my advanced polls module. What do you want want to know about it? or are you meaning pnHTML calls in general?

    -Mark

    --
    Visit My homepage and Zikula themes.
  • i was jsut using ur module as an example ...all im really trying to do is add to an admin section a yes or no question then later in my module i want to say .. if that was yes then take this ation , but if its no . take a different action ...

    thanks
  • The various bits of code in this thread do what you need.

    The formselectmultiple method of pnHTML creates the HTML chunk to display a yes/no radio selection, the pnVarCleanFromInput piece posted by Chuck gets this particular value from the submitted form variables and lastly the if statement you have allows you to do something with the variable.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • ok i think i understand most of this now .. firstly ..i already understood this part but ill include it jsut for clarity

    Code

    $row[] = $output->FormSelectMultiple('pollrecurring',array(
                                                       array('id' => 0,
                                                         'name' => 'No'),
                                                       array('id' => 1,
                                                         'name' => 'Yes')),
    creates the yes or no option in the admin menu


    the code

    Code

    <select name="pollrecurring">
    <option value=0>No
    <option value=1>Yes
    </select>


    would do the exact same thing if i were doing this in HTML


    the statment

    Code

    if ($item['pollrecurring'] == 0) {  }

    will use the information and if the value is 'no' it will take a certain action


    but the only part im hazy onn is Chucks addition

    Code

    $pollrecurring = pnVarCleanFromInput('pollrecurring');



    can someone clarify this or point me somewhere that does.. i would jsut liek to know .. what it basicaly is doing, where i should use it (thats easier to know when you know what it is :D)
  • Take a look at the API reference for docs on each part of the API. Also take a look at the comments in the template module code as these are meant to help you understand the structure of an API compliant module.

    pnVarCleanFromInput gets the value of a variable from the items submitted in a form. What the API actually does at a code level is to loop through the arguments list submitted to the function looking for the value 'pollrecurring' and then performs some cleaning on it.

    If you want to see what any API function actually does then take a look at the function itself usally in pnAPI.php, pnMod.php, pnSession.php etc. in /includes.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • ok thanks ..

    for my first code will

    Code

    <tr><td class="pn-normal">'

            ._ALLOWANONDOWNLOADS.'
    </td><td class="pn-normal">'
            ."<input type=\"radio\" name=\"xdownloads_anonadddownloadlocker\" value=\"1\" class=\"pn-normal\"".$sel_anonadddownloadlocker['
    1'].">"._YES.' &nbsp;'
            ."<input type=\"radio\" name=\"xdownloads_anonadddownloadlocker\" value=\"0\" class=\"pn-normal\"".$sel_anonadddownloadlocker['
    0'].">"._NO
            .'
    </td></tr>
    have the same effect as


    Code

    $row[] = $output->FormSelectMultiple('xdownloads_anonadddownloadlocker',array(
                                                       array('id' => 0,
                                                         'name' => 'No'),
                                                       array('id' => 1,
                                                         'name' => 'Yes')),
  • It looks ok but code doesn't display well in a forum post. Easiest way is to try it and see. Backup the original file first of course.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • yeah .. hmm well im just adding options into a pre-existant menu and the whole thind is done like the forum post way .. and i donno how to add

    Code

    $row[] = $output->FormSelectMultiple('xdownloads_anonadddownloadlocker',array(
                                                       array('id' => 0,
                                                         'name' => 'No'),
                                                       array('id' => 1,
                                                         'name' => 'Yes'))
    it just gives me errors and such .. if i want to use that is there othwer things i have to include before??

    so im using the first one ...


    ive added


    Code

    <tr><td class="pn-normal">'

            ._ALLOWANONDOWNLOADS.'
    </td><td class="pn-normal">'
            ."<input type=\"radio\" name=\"xdownloads_anonadddownloadlocker\" value=\"1\" class=\"pn-normal\"".$sel_anonadddownloadlocker['
    1'].">"._YES.' &nbsp;'
            ."<input type=\"radio\" name=\"xdownloads_anonadddownloadlocker\" value=\"0\" class=\"pn-normal\"".$sel_anonadddownloadlocker['
    0'].">"._NO
            .'
    </td></tr
    to the admin ...

    and this to the index file where i would like it


    Code

    if ($sel_anonadddownloadlocker == 0) {
          if (pnUserLoggedIn()) {
             visit($lid);
        }
       else{
             pnRedirect('user.php');
        }}
       else{
             visit($lid);
        }



    but it just acts asif i said

    Code

    if (pnUserLoggedIn()) {
             visit($lid);
        }
       else{
             pnRedirect('user.php');
        }
  • I think you need to step back a bit an understand some of the background behind what your trying to do.

    There are two types of modules in PN. API compliant and non API compliant. An API compliant module has files pnuser.php/pnadmin.php etc. and will (currently) use the pnHTML class. Non API compliant modules have files index.php/admin.php and uses echo commands to print out the HTML.

    The code you have add's an entry to the admin menu but how is this entry processed? Where is it stored? You can't just define a form entry in one place - do nothing with it and then refer to the form components name in a variable elsewhere in the code. Programming doesn't work that way.

    In your specific example You define a new field in the admin form, you capture that fields value in a form processing function, you store the result somewhere (probably in a module variable). You then access that stored result (from module variable) and can then use this to make some processing decision in the user code.

    -Mark

    --
    Visit My homepage and Zikula themes.

This list is based on users active over the last 60 minutes.