SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing arrays to template ?

    How do i pass the information that contains the form that is being build through a FormProcessor Object.
    This is where the form is being obtained -> $myForm->display();
    How do i parse this form/$myForm->display() on to
    'kontaktvoice' => 'templates/kontaktvoice.tpl'
    I is working fine when i have enetered the data which is being required but not before

    Can anybody please help thanks

    PHP Code:

    include( "class.FastTemplate.php" );
    require 
    "lib/FormProcessor.class.php";

    $voice = new FastTemplate"." );

    $voice->define( array( 

    'base'             =>  'hovedtemplates/base.tpl',
    'top'              =>  'hovedtemplates/top.tpl',
    'navigation'       =>  'hovedtemplates/navigation.tpl',
    'banner'           =>  'hovedtemplates/banner.tpl',
    'navihojre'        =>  'hovedtemplates/navihojre.tpl',
    'topfrekvens'      =>  'hovedtemplates/topfrekvens.tpl',
    'kontaktvoice'     =>  'templates/kontaktvoice.tpl'

    ));


    $dbcnx = @mysql_connect('localhost','root','');
    mysql_select_db('voice');


    // Initialize
    $fp = new FormProcessor("lib/");

    // Import the needed elements
    $fp->importElements(array(
        
    FPTextFPTextFieldFPTextAreaFPPasswordFPSelect,
        
    FPFileFPCheckBoxFPRadioFPSubmitButton

    ));

    $fp->importLayouts(array( FPColLayoutFPRowLayoutFPGridLayoutFPGroup ));
    $fp->importWrappers(array( FPTopTitleWrapper ));


    // Create the form object
    $myForm = new FPForm(array(
        
    title => 'Kontakt webmaster !',
        
    name => 'myForm',
        
    action => $PHP_SELF,
        
    display_outer_table => true,
        
    refine_owners => true,
        
    table_align => 'center',
        
    table_width => '200'
    ));


    // Wrappers
    $topWrapper = new FPTopTitleWrapper(array());

    // Define form elements
    $myForm->setBaseLayout(new FPColLayout(array(
        
    elements => array(


        
           new 
    FPTextField(array(
                
    name => navn,
                
    title => 'Dit Navn',
                
    valid_RE => FP_VALID_TITLE,
                
    wrapper => &$topWrapper,
                
    size => 25,
                
    css_style => 'width:200px;',
                
    required => true,
                
    max_length => 256
            
    )),
            

              

                new 
    FPRowLayout(array(
                
    elements => array(
                   
                    new 
    FPTextField(array(
                        
    name => email,
                        
    title => 'E-mail',
                        
    valid_RE => FP_VALID_EMAIL,
                        
    wrapper => &$topWrapper,
                        
    size => 37,
                        
    css_style => 'width:200px;',
                        
    required => false,
                        
    max_length => 256
                    
    ))
                ),
                )),
       
        new 
    FPText(array(
             
    text =>
             
    'Giv en kommentar:'
            
    )),
            
                new 
    FPTextArea(array(
                    
    name => 'comments',
                    
    title => 'Your Comment',
                    
    max_length => 2048,
                    
    wrapper => &$leftWrapper
                
    )),        
                
                
        
        new 
    FPRowLayout(array(
            
    table_align => center,
            
    table_padding => 15,
            
    elements => array(
                new 
    FPSubmitButton(
                array(
                    
    name => 'submit',
                    
    title => '    Send    '
                
    )),
                
                
        
            )
            )),
            
            
            new 
    FPText(array(
             
    text =>
             
    '<b>OBS:</b> Jeg besvarer ikke musikspørgsmål !<br>Musikspørgsmål skal sendes til <a href=\"mail:studie@voice.dk\"><b>studie@voice.dk</b></a>'
            
    )),
                

            
        )
    )));


    // Obtain submitted data and check the values correctness

    if ($myForm->getSubmittedData()  &&  $myForm->isDataValid()) {

    $elements $myForm->getElementValues();


    $table "<table border='1' align='center'>";

    $elementsimplode(", ",$elements);

    $sql "INSERT INTO form SET
                data='
    $elements'";

    if (@
    mysql_query($sql)) {

    $table .= "<tr><td>Vi har modtaget dine oplysninger tak</td></tr>";

    else {

    $table .= "<tr><td>Der skete en fejl !</td></tr>";

      }

    $table .= "<tr><td>$elements</td></tr>";
    $table .= "</table>";



    else {

    $myForm->display();

    }

    $voice->assign( array(

    FORM => $table

    ));

    $voice->parse('TEXT''kontaktvoice');
    $voice->parse('TOP''top');
    $voice->parse('FREKVENS''topfrekvens');
    $voice->parse('NAVIGATION''navigation');
    $voice->parse('BANNER''banner');
    $voice->parse('NAVIHOJRE''navihojre');
    $voice->parse('BASE''base');
    $voice->FastPrint('BASE'); 
    Last edited by abo2512; Jun 12, 2003 at 07:07.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •