Download the PHP package heimrichhannot/contao-amp-bundle without Composer

On this page you can find all versions of the php package heimrichhannot/contao-amp-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package contao-amp-bundle

Contao AMP Bundle

This bundle offers functionality concerning Accelerated Mobile Pages (AMP) for the Contao CMS.

Features

Setup

Installation

  1. Install via composer: composer require heimrichhannot/contao-amp-bundle
  2. Update your database.
  3. Prepare your page template for Contao Head Bundle (needed for the amphtml link element).

First steps

  1. Create an ordinary layout and assign fe_page_amp.html5 as template. Click Add AMP support.
  2. Navigation to the root page where you want to add AMP support, set AMP support to active and choose the layout created in step 1.
  3. In order to show your website in AMP mode simply append the GET parameter amp=1 to your URL, i.e. https://www.example.org/articlehttps://www.example.org/article?amp=1

Usage

Menu/Navigation

This bundle comes with an custom frontend module for navigation. It renders the menu as sidebar and add the option to render sub pages as accordions. We recommend to use it for the navigation on your amp page.
Since amp-sidebar must sit directly within the body element, put the navigation module into the header section of your template (we removed container elements for header section in our template).

Support custom templates

  1. To create an amp version for any template, create a new template file with the same name and add _amp as suffix, e.g. ce_my_content_element_amp.html5 or ce_my_content_element_amp.html.twig.

  2. Register the template in your project config

  3. If your template/element needs amp components to work, update your configuration accordingly:

If you need more control about template context or components, use the PrepareAmpTemplateEvent. If the element template is amp compatible without modifications or your element will be only used in amp context, you can set huh_amp.template.[template].amp_template to true, see configuration section.

Encore Bundle

If you use encore bundle, just create an amp encore entry and add it to your amp layout. Only css assets from the layout will be added.

Templates

This section will give some hints for creating amp valid templates.

Images

AMP Bundle ship with an image template, that can be included. If you already use the utils bundle image template, you just need to replace the template name:

If you don't want the contao image container around, you can also include just the image element {{ include('@HeimrichHannotAmp/picture/picture_amp.html.twig') }}.

Convert html code to amp-html

Since bundle version 0.3

If you use the convert_html option for a registered template, the resulting html code after parsing the templates will be converted to amp-html code. This may come handy for example ce_html or mod_html templates. To use this feature, you must install lullabot/amp library, otherwise a warning in thrown when set this option to true. This bundle extends the library functionality with additional svg-support for img tags. Keep in mind that an automatic conversation maybe not complete or good as a manual conversation.

Developers

Events

Class Description
PrepareAmpTemplateEvent Prepare template, add/change amp components, change the template name.

Supported content elements

Contao content element Contao template AMP component Notes
ContentAccordion ce_accordionSingle.html5 accordion single element accordions
ContentAccordionStart ce_accordionStart.html5 accordion
ContentAccordionStop ce_accordionStop.html5 accordion
ContentImage ce_image.html5 image
ContentMedia ce_player.html5 audio or video aka "Audio/Video"; if isVideo is set in the template, the amp component "video" is used
ContentYouTube ce_youtube.html5 youtube core content element or heimrichhannot/contao-youtube-bundle
ContentSlick ce_slick.html5 carousel heimrichhannot/contao-slick-bundle

Supported modules

Contao module Contao template AMP component
ModuleNavigation mod_navigation.html5 sidebar + accordion

AMP Validation

You can validate your AMP page by appending #development=1 to your url.

Things to consider:

Meta-Tag handling in fe_page

The meta tags are handled using heimrichhannot/contao-head-bundle and rendered as follows:

Hint: If you use fe_page_amp.html5 in your AMP layout, you won't have to take care of this.

Override templates

HTML5 templates

These can be overridden as usual by putting a file with the same name into your project's templates directory or in the templates directory of one of your modules.

Twig templates

These can be overridden by putting a file with the same name into your project's app/Resources/views directory or in the src/Resources/views directory of one of your bundles (these bundles must load after the contao-amp-bundle; you can specify this in your bundle's Plugin.php).

Responsive images: Contao vs. AMP

Keep in mind: If you didn't specify image sizes in Contao, you can skip this chapter.

In Contao responsive images are built with "archives" (tl_image_size and tl_image_size_item). In tl_image_size you can define a default image size and in tl_image_size_item instances more sizes depending on a given media query.

In AMP on the other hand there's no such thing as a default case, so you need to create it explicitly. Also you have to add media-queries for each and every tl_image_size_item so that you don't have duplicates.

So you have 2 options:

  1. Assign an image size with no child elements to your image, i.e. only tl_image_size.
  2. Create tl_image_size_item instances so that you have one for every situation that can happen. Example:

SVG images

If you use svg-images ensure that they have assigned width and height attributes on the <svg> element. Otherwise they wont have dimensions in their amp-version and the lazy loading component requires width and height for aspect ratio padding.

For non-amp version simply add the following css rules and attach .img-fluid css class to make svg responsive again:

Documentation

Configuration - The complete configuration and examples

Known limitations


All versions of contao-amp-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
contao/core-bundle Version ^4.9
heimrichhannot/contao-head-bundle Version ^1.7
heimrichhannot/contao-twig-support-bundle Version ^1.5
heimrichhannot/contao-utils-bundle Version ^2.225
matthiasmullie/minify Version ^1.3
psr/container Version ^1.0 || ^2.0
symfony/event-dispatcher-contracts Version ^1.0 || ^2.0 || ^3.0
symfony/http-foundation Version ^4.4 || ^5.4
symfony/polyfill-php80 Version ^1.27
symfony/service-contracts Version ^1.0 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package heimrichhannot/contao-amp-bundle contains the following files

Loading the files please wait ....