Renderlet

Skip to end of metadata
Go to start of metadata

The renderlet is a special container which is able to receive every object in Pimcore (Documents, Assets, Objects).
You can decide in your controller/action what to do with the object which is linked to the renderlet.
So it's possible to make a multifunctional dropbox in editmode where the editor can drop anything on it.

Configuration

Name
Type
Description
Mandatory
width
integer
Width of the renderlet in pixel  
height
integer
Height of the renderlet in pixel
 
module
string
Specify module (default: website)
 
controller
string
Specify controller X
action
string
Specify action X
template
string
Specify template
 
title
string
Add a title to the box in editmode  
reload bool Reload document on change (since 1.4.2)
 

Optionally you can pass every parameter (with a simple data type) you like to the renderlet which can be accessed by the configured controller with $this->_getParam("yourKey").

In the configured Controller Action

In the target controller action you get the follwing parameters which can be accessed by $this->_getParam("key").

Name
Type
Description
document
Document
If the element which is dropped on the renderlet is a document this parameter is defined.
id
integer The id of the element assigned to the renderlet
type
string
The type of the element assigned to the renderlet (document|asset|object)
subtype
string
The subtype of the element assigned to the renderlet (folder, image, link, page, classname, ...)

If you have defined custom parameters to the renderlet configuration you can access them also with $this->getParam()

Basic Example

 <?php echo $this->renderlet("gallery", array(
    "controller" => "content",
    "action" => "gallery",
    "title" => "Drag an asset folder here to get a gallery",
    "height" => 400
)); ?>

Full Example

 // code in the template / view
 // this goes in the block view
<?php echo $this->renderlet("gallery", array(
    "controller" => "content",
    "action" => "gallery",
    "title" => "Drag an asset folder here to get a gallery",
    "height" => 400
)); ?>

 // and this goes in the content view in the scripts/content- folder

<?php 
foreach ($this->assets as $asset) {
	echo '<img src="'.$asset.'"/>';
}
?>

// code in the controller/action

<?php

class ContentController extends Website_Controller_Action {
    
    
    public function galleryAction () {
                
        if($this->_getParam("type") == "asset") {
            if($asset = Asset::getById($this->_getParam("id"))) {
                if($asset->getType("folder")) {
                    $childs = $asset->getChilds();
                    $this->view->assets = $childs;
                }
            }
        }
    }
}

?>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 21

    Alexey says:

    I can't get this working using simple data! Pls help me, where should i ins...

    I can't get this working using simple data!

    Pls help me, where should i insert this code???

    <?php
    foreach ($this->assets as $asset) {
    	echo '<img src="'.$asset.'"/>';
    }
    ?>
    

    First I inserted this line in /views/content/default.php in blocktype array,

    array("gallery","Gallery"),
    

    then I created file gallery.php in /views/content/ and paste code there, but it doesnt seem to work.

    1. Nov 23

      Alexey says:

      I've get this working! :) very nice. the problem was in difference between ...

      I've get this working! :) very nice.

      the problem was in difference between controller code in docs and in example data.

  2. Feb 29

    christian bretzke says:

    hi again, is there a possibility to set restrictions to the files the renderlet...

    hi again,

    is there a possibility to set restrictions to the files the renderlet can obtain, so the backend-user might not drop everything in it?

    1. Apr 15

      Alexey says:

      This link may help you, but i think it works only with Documents.  I ...

      This link may help you, but i think it works only with Documents. 

      I am interested in renderlet functionality too,for some sort of Product Catalog.For now I'm reading api :) I think its the best practice