PHP Classes

File: example_5_css_bootstrap

Recommend this page to a friend!
  Classes of Tony Frezza   HTML Generate   example_5_css_bootstrap   Download  
File: example_5_css_bootstrap
Role: Example script
Content type: text/plain
Description: Example 5 Usage with Css Bootstrap
Class: HTML Generate
Generate HTML from arrays
Author: By
Last change: edit class name to UML template
Date: 7 years ago
Size: 7,317 bytes
 

Contents

Class file image Download
<?php

/**
 * @author Tony Frezza
 * @copyright 2017
 *
 *
 * After running the script, see the generated html source code
 * Example based link: https://v4-alpha.getbootstrap.com/examples/narrow-jumbotron/
 *
 */
 
   
include('html.php');
 
   
$html = new Html;
   
   
$idContainer = $html->add(
        array(
           
'tag' => 'div',
           
'class' => 'container',
        )
    );
   
   
$idHeader = $html->add(
        array(
           
'tag' => 'div',
           
'class' => 'header clearfix',
           
'parent_id' => $idContainer,
        )
    );
   
   
$idNav = $html->add(
        array(
           
'tag' => 'nav',
           
'parent_id' => $idHeader,
        )
    );
   
   
$html->add(
        array(
           
'tag' => 'ul',
           
'class' => 'nav nav-pills float-right',
           
'parent_id' => $idNav,
           
'children' => array(
                array(
                   
'tag' => 'li',
                   
'class' => 'nav-item',
                   
'children' => array(
                        array(
                           
'tag' => 'a',
                           
'class' => 'nav-link active',
                           
'href' => '#',
                           
'text' => 'Home ',
                           
'children' => array(
                                array(
                                   
'tag' => 'span',
                                   
'class' => 'sr-only',
                                   
'text' => '(current)',
                                )
                            )
                        ),
                    )
                ),
                array(
                   
'tag' => 'li',
                   
'class' => 'nav-item',
                   
'children' => array(
                        array(
                           
'tag' => 'a',
                           
'class' => 'nav-link',
                           
'href' => '#',
                           
'text' => 'About',
                        ),
                    )
                ),
                array(
                   
'tag' => 'li',
                   
'class' => 'nav-item',
                   
'children' => array(
                        array(
                           
'tag' => 'a',
                           
'class' => 'nav-link',
                           
'href' => '#',
                           
'text' => 'Contact',
                        ),
                    )
                ),
            )
        )
    );
   
   
$html->add(
        array(
           
'tag' => 'h3',
           
'class' => 'text-muted',
           
'text' => 'Project name',
           
'parent_id' => $idNav,
        )
    );
   
   
$idJumbotron = $html->add(
        array(
           
'tag' => 'div',
           
'class' => 'jumbotron',
           
'parent_id' => $idContainer,
        )
    );
   
   
$html->add(
        array(
           
'tag' => 'h1',
           
'class' => 'display-3',
           
'text' => 'Jumbotron heading',
           
'parent_id' => $idJumbotron,
        )
    );
   
   
$html->add(
        array(
           
'tag' => 'p',
           
'class' => 'lead',
           
'text' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.',
           
'parent_id' => $idJumbotron,
        )
    );
   
   
$html->add(
        array(
           
'tag' => 'p',
           
'parent_id' => $idJumbotron,
           
'children' => array(
                array(
                   
'tag' => 'a',
                   
'class' => 'btn btn-lg btn-success',
                   
'href' => '#',
                   
'role' => 'button',
                   
'text' => 'Sign up today',
                )
            )
        )
    );
   
   
$idRowMarketing = $html->add(
        array(
           
'tag' => 'div',
           
'class' => 'row marketing',
           
'parent_id' => $idContainer,
        )
    );
   
   
/**
     * For loop to repeat adding nodes
     */
    
   
for($i=0; $i<2; $i++){
       
       
$html->add(
            array(
               
'tag' => 'div',
               
'class' => 'col-lg-6',
               
'parent_id' => $idRowMarketing,
               
'children' => array(
                    array(
                       
'tag' => 'h4',
                       
'text' => 'Subheading',
                    ),
                    array(
                       
'tag' => 'p',
                       
'text' => 'Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.',
                    ),
                    array(
                       
'tag' => 'h4',
                       
'text' => 'Subheading',
                    ),
                    array(
                       
'tag' => 'p',
                       
'text' => 'Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.',
                    ),
                    array(
                       
'tag' => 'h4',
                       
'text' => 'Subheading',
                    ),
                    array(
                       
'tag' => 'p',
                       
'text' => 'Maecenas sed diam eget risus varius blandit sit amet non magna.',
                    ),
                )
            )
        );
    }
   
   
   
$html->add(
        array(
           
'tag' => 'footer',
           
'class' => 'footer',
           
'parent_id' => $idContainer,
           
'children' => array(
                array(
                   
'tag' => 'p',
                   
'text' => '&copy; Company ' . date('Y'),
                )
            )
        )
    );
   
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="Tony Frezza" />

    <title>Html Class - Bootstrap Css Example</title>
   
    <!-- Bootstrap core CSS -->
    <link href="https://v4-alpha.getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="https://v4-alpha.getbootstrap.com/examples/narrow-jumbotron/narrow-jumbotron.css" rel="stylesheet">
</head>

<body>
    
    <?php
       
       
echo $html->getHtml();
       
   
?>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="https://v4-alpha.getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>