Href (1 to 1 Relation)

Skip to end of metadata
Go to start of metadata

Href provides to create a reference to an other element in pimcore (document, asset, object).
This can be useful to link a video for example (in editmode show the href to link the video out of the assets, outside embed a object code an make a reference to the video.).

In frontend-mode the href returns the path of the linked element.

Configuration

Name
Type
Description
only
enum (document|asset|object)
Restrict to type (only one is possible) DEPRECATED since pimcore 1.3.3
types array Allowed types (document, asset, object), if empty all types are allowed Feature included since pimcore 1.3.3
subtypes array Allowed subtypes grouped by type (folder, page, snippet, image, video, object, ...), if empty all subtypes are allowed (see example below) Feature included since pimcore 1.3.3
classes array Allowed object class names, if empty all classes are allowed Feature included since pimcore 1.3.3
reload true|false true triggers page reload on each change Feature included since pimcore 1.3.3
width int Width of the field in pixel  
uploadPath string Target path for (inline) uploaded assets (since 1.4.6)
Feature included since pimcore 1.4.6

Properties and methods

Name
Type
Description
getElement()
Document|Asset|Object_Abstract
Object assigned to the href
getFullPath()
string
Get the path of the assigned element
element
Document|Asset|Object_Abstract
The property for getElement() it's a good idea to use the getter

Examples

// Basic usage
<?php echo $this->href("myHref"); ?>


// Usage with restriction
<?php echo $this->href("myHref",array(
    "types"=>array("asset"),
    "subtypes"=>array(
        "asset" => array("video","image")
    )
)); ?>

// Advanced usage with getElement()
<?php if ($this->editmode) { ?>
    <?php echo $this->href("myHref"); ?>
<?php } else { ?>
    <?php
        $myHref = $this->href("myHref")->getElement();
        echo $myHref->getName();
    ?>
<?php } ?>

// Advanced usage (the video example)
<?php if ($this->editmode) { ?>
    <?php echo $this->href("myHref"); ?>
<?php } else { ?>
    <?php if ($this->href("myHref") instanceof Asset_Video) { ?>
        <script type="text/javascript">
            var params = {
                quality: 'high'
            };
            var flashvars = {
                videoFile : "<?= $this->href("myHref")->getFullPath() ?>"
            };
            swfobject.embedSWF("/static/swf/player.swf", "videoPlayerElement", "400", "300", "9.0.0", "", flashvars, params);
        </script>
    <?php } ?>
<?php } ?>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 24

    Spank Master says:

    "width" is also interpreted as configuration option

    "width" is also interpreted as configuration option