Commit 2fdbae56 authored by Nigel McNie's avatar Nigel McNie
Browse files

Show the title of a folder as the blockinstance title

parent c1468d02
......@@ -32,6 +32,21 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return get_string('title', 'blocktype.file/folder');
}
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi) {
$configdata = $bi->get('configdata');
if (!empty($configdata['artefactid'])) {
require_once(get_config('docroot') . 'artefact/lib.php');
$folder = artefact_instance_from_id($configdata['artefactid']);
return $folder->get('title');
}
return '';
}
public static function get_description() {
return get_string('description', 'blocktype.file/folder');
}
......@@ -44,6 +59,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['hidetitle'] = true;
// This can be either an image or profileicon. They both implement
// render_self
......@@ -72,7 +88,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('folder'),
'title' => get_string('folder', 'artefact.file'),
'defaultvalue' => $default,
'rules' => array(
'required' => true,
......
......@@ -743,6 +743,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$smarty->assign('title', $this->get('title'));
$smarty->assign('description', $this->get('description'));
$smarty->assign('viewid', $options['viewid']);
$smarty->assign('hidetitle', isset($options['hidetitle']) ? $options['hidetitle'] : false);
if ($childrecords = $this->folder_contents()) {
$this->add_to_render_path($options);
......
<div>
<h3>{$title|escape}</h3>
{if !$hidetitle}<h3>{$title|escape}</h3>{/if}
<div>{$description|escape}</div>
<div>
{if (isset($children))}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment