Fork me on GitHub

Correct usage of Linebreak(x); I/O mode problem, I think...  Bottom

  • I'm using this block of code below, and trying to separate the two fields with a linebreak. No matter how I set up the I/O modes, it seems to put all the line breaks above the form elements... I've searched the forums and studied pnHTML.php, but nothing I've tried will pull it off... I also read another post by MarkWest that spelled out a lot about I/O modes, but I couldn't get it right...

    Any thoughts?

    Code

    // USER -- NAME
            $row = array();
            $output->SetInputMode(_PNH_VERBATIMINPUT);
            $output->SetOutputMode(_PNH_RETURNOUTPUT);
            $row[] = $output->Text('Your name:');
            $row[] = $output->FormText('AlarSenderName', '', 25, 50);
        $output->SetOutputMode(_PNH_PARSEOUTPUT);
            $output->TableAddrow($row, 'left', 'middle');
                   
        // USER -- EMAIL
            $row = array();
            $output->SetInputMode(_PNH_VERBATIMINPUT);
            $output->SetOutputMode(_PNH_RETURNOUTPUT);
            $row[] = $output->Text('Your email:');
            $row[] = $output->FormText('AlarSenderMail', '', 25, 50);
        $output->SetOutputMode(_PNH_PARSEOUTPUT);
            $output->TableAddrow($row, 'left', 'middle');


    Thanks,

    John

    BTW...this isn't the entire code...just the block in question...(ie, all this IS in a form...) ;)
  • At a guess the problem is one of the markup generated by the pnHTML class and the way browsers render that markup. Since your using table rows for the form you end up with some output like

    Code

    <table>
    <tr><td>some text</td><td>some form element</td></tr>
    <tr><td>some text</td><td>some form element</td></tr>
    ....
    </table>


    Now if we try to add a line break into the code using

    Code

    ....
    $output->TableAddRow(....);
    $output->LineBreak(x);
    $output->TableAddRow(....);


    the resultant HTML will look like

    Code

    <table>
    <tr><td>some text</td><td>some form element</td></tr><br />
    <tr><td>some text</td><td>some form element</td></tr><br />
    ....
    </table>


    However this isn't valid HTML since you can't have any elements in this part of the tables structure. Elements must either be in a table cell or outside of the table.

    Two workarounds...

    1) Use multiple tables with the linebreak between them
    2) At the line break to the end of one of the table cells i.e.

    Code

    $row[] = $output->Text('some text');
    $row[] = $output->FormText(....) . $output->LineBreak(x);
    $output->TableAddrow(.....).


    Alternatively look at pnRender where everything is in easily editable templates.

    Hope this helps.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Thanks Mark,

    Yes, this helps... As a new mod developer, I decided to go with pnHTML instead of pnRender mainly due to the fact that the majority of already answered posts seemed more geared toward that... I'm just learning PHP and new to procedural coding, let alone OO stuff. But I'm hangin' in... I'll definitely get with the pnRender as soon as the transition smoothes out...

    Thanks again,

    John
  • Just a quick update for anyone who comes across the thread...

    Yes, it worked. (adding the Linebreak() to any given row[])
  • John,

    When you do i've witten some tips on porting pnHT…modules to pnRender which you may find useful. The only difference with pnRender'ed modules is the output layer.

    The advantage for you as a developer is it's a lot faster to develop the look and feel of a module using a standard visual web editor (say dreamweaver). The advantage for your users are complete control over the look and feel of the module. Personally I now can't imagine myself working with pnHTML.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • That's some invaluable information...thanks for making it available... I'm starting to get the idea that pnRender is more my style...
  • John,

    I many people like to work with existing examples while learning so....

    If you have a .750 test install there are a few modules there that are pnRender based to get you started. Firstly the example module - this is exactly the same as the template module but with the output templated using pnRender. The module was renamed for obvious reasons. You then also have pnRender itself, Xantnia and Mailer to work with.

    Third party modules that are templates include Pagesetter, Photoshare and my advanced polls module. These should be enough to give some decent examples of how to approach a pnRender'ed module.

    Have fun and any questions you have just shout....

    -Mark

    --
    Visit My homepage and Zikula themes.

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