PHP Classes
elePHPant
Icontem

File: example/smallexample-amp.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  PHP AMP Page Generator  >  example/smallexample-amp.php  >  Download  
File: example/smallexample-amp.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP AMP Page Generator
Generate HTML for using as Google AMP site
Author: By
Last change:
Date: 9 months ago
Size: 1,311 bytes
 

Contents

Class file image Download
<?php

use eftec\AmpGeneratorOne\AmpGeneratorOne;
use
eftec\AmpGeneratorOne\FooterModel;
use
eftec\AmpGeneratorOne\HeaderModel;
use
eftec\AmpGeneratorOne\HeadModel;
use
eftec\AmpGeneratorOne\LinkModel;
use
eftec\AmpGeneratorOne\SectionModel;
// example
include "../lib/AmpGeneratorOne.php";

$base = dirname('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); // this operation is not safe, it's only an example

$amp=new AmpGeneratorOne("https://www.canonical.com",$base,"#4040ff", "#197bc6","text-white");

// #header
$amp->startAmp(new HeaderModel("description","title",$base."/resources/favicon.ico"));

// #sidebar

$menu=array();
$links=array("Cupcakes","Cake","Muffin","Coffee");
foreach(
$links as $link) {
   
$menu[] = new LinkModel($link, "https://wwww.canonical.com/id/".$link, "");

}
$amp->sidebar($menu);

// #1 head
$amp->head(new HeadModel("",$base."/resources/logo/logo.png"),70,70);

// #
$amp->setBackgroundColor("rgb(0, 174, 239)")->setClassTextColor("text-white")->setClassTextColor("text-white")->sectionFirst(new SectionModel("Title","description"));

// #5 footer
$amp->sectionFooter(new FooterModel("Copyright something(c)","See as desktop"));

$amp->render(); // you could render to output
$amp->renderToFile("smallexample-generated.html"); // or, you could render to file. PICK ONE