PHP Classes
elePHPant
Icontem

View: Generate HTML for page views from variable values

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-02-11 (9 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 168 This week: 2All time: 8,476 This week: 216Up
Version Licenses PHP version Categories
view 1.1Freely Distributable7HTML, Templates, Design Patterns, PHP 7
Description Author

This class can generate HTML for page views from variable values.

It takes the name of a HTML template file that will be used to define the core of a page that will be the current script output.

The class can replace some given variable values in the template and will use the result to replace a main layout HTML template file to generate the final output.

  Performance   Level  

Details

View

Generate Views from main Layout and HTML files with PHP

simple as:

$view = new View();

// Get contact.html and load into visitor_layout.html
$view->setView('contact', 'visitor_layout');

// Add <script> tag to <head> section
$view->addHeader('js/jquery.min.js');

// Add 'title' variable to <body> section
$view->add(['title' => 'Hello World!']);

// Print on screen
$view->render();

visitor_layout.html example:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Example</title>
        
        {headers}
        
    </head>
    <body>
    
        {content}
    
    </body>
</html>

contact.html example:

<h1>{title}</h1>

  • TODO: - Set Arrays on variable views.

_Cause we can only set strings for now._

  Files folder image Files  
File Role Description
Files folder imagepublic (2 directories)
Files folder imageviews (1 file, 1 directory)
Accessible without login Plain text file demo.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation
Plain text file View.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:168
This week:2
All time:8,476
This week:216Up