Download the PHP package jagilpe/ajax-blocks-bundle without Composer

On this page you can find all versions of the php package jagilpe/ajax-blocks-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 ajax-blocks-bundle

AjaxBlocksBundle

AjaxBlocksBundles is a Symfony bundle that provides an easy way to render in a Twig template blocks that can be updated using ajax requests.

Build Status codecov Latest Stable Version License

Installation

You can install the bundle using composer:

or add the package to your composer.json file directly.

To enable the bundle, you just have to register the bundle in your AppKernel.php file:

Then you have to add the route required for reloading the blocks. In app/config/routing.yml

Finally you have to include the provided javascript file somewhere in your base template. If you use assetic to manage the assets:

This javascript depends on jQuery, so you have to load it somewhere in the template before this file.

Usage

Basic usage

Creating an ajax block

You can write a block to be rendered as an ajax block exactly as you would write if you would embed it in a template rendering directly the output of a controller.

Write a controller that builds and returns the desired block as usual:

There is no need to define a route for this controller.

Embed the block in the page

To include the block in the page simply insert it the template using the jgp_ajax_block twig function, passing the controller as the first parameter.

Reloading the block

The main goal of this bundle is to easily divide the page in blocks that can be independently refreshed without having to reload all the page. The logic that triggers this block reload is part of the logic of the application and should be implemented in javascript as part of the application's frontend.

We can access the ajax block through the selector [data-target="jgp-ajax-block"] and reload its content invoking the reloadBlock action of the jgpAjaxBlock jQuery plugin.

The following code would reload the content of all the ajax blocks present in the page:

If we only want to reload one determined block, we should wrap it with another element and select it through it:

Advanced usage

Passing parameters to the block

You can pass parameters to the block exactly the same way you would do it with another controller, but with one important restriction: they must be strings. This is because the block is reloaded using an ajax call, and therefore this parameters must be encoded in the url of this call. If for example you wanted to pass an entity to the controller, you should pass the id of the entity and then load it in the controller's code.

The parameters should be passed as an array in the second parameter of the jgp_ajax_block function in the template.

Passing options to the jQuery plugin

By default the jQuery plugin is automatically loaded with the page load. To be able to customize the load of the plugin we have to disable the auto load of the plugin. This can be done by passing the option autoload as false in the third parameter of the jgp_ajax_block twig function.

After that you should load the plugin in the javascript code of your frontend with the custom options you want.

Adding a reload callback to the block

You can pass a reload callback to the jQuery plugin that controls the block by passing it as an option. This callback receives the reloaded block as parameter. For this to work the autoload option of the block must be disabled.

API Reference

http://api.gilpereda.com/ajax-blocks-bundle/master


All versions of ajax-blocks-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
symfony/http-kernel Version ~2.8|~3.0
twig/twig Version ~1.0|~2.0
symfony/templating Version ~2.8|~3.0
symfony/twig-bundle Version ~2.8|~3.0
symfony/twig-bridge Version ~2.8|~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 jagilpe/ajax-blocks-bundle contains the following files

Loading the files please wait ....