Joomdle Iframe wrapper wont expand correctly to fit content

More
13 years 4 months ago #1 by Ash
Hi guys, i am using Joomla 2.5, with Moodle 2.3, and Joomdle R09.....

I am having a problem getting Joomdle content to fit correctly in the wrapper. The wrapper works fine when Moodles main content needs to expand, but when its left or right column needs to expand it gets hidden.

I have tried various settings in Joomla's configurations but cant get it to display correctly. I have also noticed that there was the same problems a while back on previous versions of Joomdle, so i was hoping that a fix has been developed.

Any help would be greatly appreciated.

Thanks in advance.

Please Log in or Create an account to join the conversation.

More
13 years 4 months ago #2 by Antonio Durán
Hi.
Unfortunately, there is currently not fix for this.

Please Log in or Create an account to join the conversation.

More
13 years 2 months ago #3 by Marc Hall
in /your moodle directory/theme/joomdledemo/layout/default.php
just before the closing </head> add:
Code:
<script> function toggle(obj) { var el = document.getElementById(obj); if ( el.style.display != 'block' ) el.style.display = 'block'; else el.style.display = 'none'; parent.alertsize(document.body.clientHeight); } </script>

in the <body> tag add this:
Code:
onload="parent.alertsize(document.body.clientHeight);"

then directly under that add:
Code:
<div style="display:none;" id="moreheight"></div>

in the joomdledemo theme for moodle (2+) in config.php
below:
Code:
$THEME->name = 'joomdledemo'; $THEME->parents = array('base');

add this:
Code:
$THEME->rendererfactory = 'theme_overridden_renderer_factory';

Next add a new file to your joomdledemo directory named renderers.php
and add this to it:
Code:
<?php class theme_joomdledemo_core_renderer extends core_renderer { } include_once($CFG->dirroot . "/blocks/settings/renderer.php"); class theme_joomdledemo_block_settings_renderer extends block_settings_renderer { protected function navigation_node(navigation_node $node, $attrs=array()) { $items = $node->children; // exit if empty, we don't want an empty ul element if ($items->count()==0) { return ''; } // array of nested li elements $lis = array(); foreach ($items as $item) { if (!$item->display) { continue; } $isbranch = ($item->children->count()>0 || $item->nodetype==navigation_node::NODETYPE_BRANCH); $hasicon = (!$isbranch && $item->icon instanceof renderable); if ($isbranch) { $item->hideicon = true; } $content = $this->output->render($item); // this applies to the li item which contains all child lists too $liclasses = array($item->get_css_type()); $liexpandable = array(); if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0 && $item->nodetype==navigation_node::NODETYPE_BRANCH)) { $liclasses[] = 'collapsed'; } if ($isbranch) { $liclasses[] = 'contains_branch'; $liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true"); } else if ($hasicon) { $liclasses[] = 'item_with_icon'; } if ($item->isactive === true) { $liclasses[] = 'current_branch'; } $liattr = array('class' => join(' ',$liclasses)) + $liexpandable; // class attribute on the div item which only contains the item content $divclasses = array('tree_item'); if ($isbranch) { $divclasses[] = 'branch'; } else { $divclasses[] = 'leaf'; } if (!empty($item->classes) && count($item->classes)>0) { $divclasses[] = join(' ', $item->classes); } $divattr = array('class'=>join(' ', $divclasses)); if (!empty($item->id)) { $divattr['id'] = $item->id; } $content = "<a href=\"javascript:toggle('moreheight')\">" . html_writer::tag('p', $content, $divattr) . $this->navigation_node($item) . "</a>"; if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) { $content = html_writer::empty_tag('hr') . $content; } $content = html_writer::tag('li', $content, $liattr); $lis[] = $content; } if (count($lis)) { return html_writer::tag('ul', implode("\n", $lis), $attrs); } else { return ''; } } } include_once($CFG->dirroot . "/course/renderer.php"); class theme_joomdledemo_core_course_renderer extends core_course_renderer { /** * Renderers a category for use with course_category_tree * * @param array $category * @param int $depth * @return string */ protected function course_category_tree_category(stdClass $category, $depth=1) { $content = ''; $hassubcategories = (isset($category->categories) && count($category->categories)>0); $hascourses = (isset($category->courses) && count($category->courses)>0); $classes = array('category'); if ($category->parent != 0) { $classes[] = 'subcategory'; } if (empty($category->visible)) { $classes[] = 'dimmed_category'; } if ($hassubcategories || $hascourses) { $classes[] = 'with_children'; if ($depth > 1) { $classes[] = 'collapsed'; } } $categoryname = format_string($category->name, true, array('context' => context_coursecat::instance($category->id))); $content .= html_writer::start_tag('div', array('class'=>join(' ', $classes))); $content .= html_writer::start_tag('div', array('class'=>'category_label', 'onclick'=>'javascript:setTimeout(function() {toggle(\'moreheight\');},0)')); $content .= html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $categoryname, array('class'=>'category_link')); $content .= html_writer::end_tag('div'); if ($hassubcategories) { $content .= html_writer::start_tag('div', array('class'=>'subcategories')); foreach ($category->categories as $subcategory) { $content .= $this->course_category_tree_category($subcategory, $depth+1); } $content .= html_writer::end_tag('div'); } if ($hascourses) { $content .= html_writer::start_tag('div', array('class'=>'courses')); $coursecount = 0; $strinfo = new lang_string('info'); foreach ($category->courses as $course) { $classes = array('course'); $linkclass = 'course_link'; if (!$course->visible) { $linkclass .= ' dimmed'; } $coursecount ++; $classes[] = ($coursecount%2)?'odd':'even'; $content .= html_writer::start_tag('div', array('class'=>join(' ', $classes))); $content .= html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), format_string($course->fullname), array('class'=>$linkclass)); $content .= html_writer::start_tag('div', array('class'=>'course_info clearfix')); // print enrol info if ($icons = enrol_get_course_info_icons($course)) { foreach ($icons as $pix_icon) { $content .= $this->render($pix_icon); } } if ($course->summary) { $url = new moodle_url('/course/info.php', array('id' => $course->id)); $image = html_writer::empty_tag('img', array('src'=>$this->output->pix_url('i/info'), 'alt'=>$this->strings->summary)); $content .= $this->action_link($url, $image, new popup_action('click', $url, 'courseinfo'), array('title' => $this->strings->summary)); } $content .= html_writer::end_tag('div'); $content .= html_writer::end_tag('div'); } $content .= html_writer::end_tag('div'); } $content .= html_writer::end_tag('div'); return $content; } } include_once($CFG->dirroot . "/blocks/navigation/renderer.php"); class theme_joomdledemo_block_navigation_renderer extends block_navigation_renderer { /** * Produces a navigation node for the navigation tree * * @param array $items * @param array $attrs * @param int $expansionlimit * @param array $options * @param int $depth * @return string */ protected function navigation_node($items, $attrs=array(), $expansionlimit=null, array $options = array(), $depth=1) { // exit if empty, we don't want an empty ul element if (count($items)==0) { return ''; } // array of nested li elements $lis = array(); foreach ($items as $item) { if (!$item->display && !$item->contains_active_node()) { continue; } $content = $item->get_content(); $title = $item->get_title(); $isexpandable = (empty($expansionlimit) || ($item->type > navigation_node::TYPE_ACTIVITY || $item->type < $expansionlimit) || ($item->contains_active_node() && $item->children->count() > 0)); $isbranch = $isexpandable && ($item->children->count() > 0 || ($item->has_children() && (isloggedin() || $item->type <= navigation_node::TYPE_CATEGORY))); // Skip elements which have no content and no action - no point in showing them if (!$isexpandable && empty($item->action)) { continue; } $hasicon = ((!$isbranch || $item->type == navigation_node::TYPE_ACTIVITY || $item->type == navigation_node::TYPE_RESOURCE) && $item->icon instanceof renderable); if ($hasicon) { $icon = $this->output->render($item->icon); } else { $icon = ''; } $content = $icon.$content; // use CSS for spacing of icons if ($item->helpbutton !== null) { $content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton')); } if ($content === '') { continue; } $attributes = array(); if ($title !== '') { $attributes['title'] = $title; } if ($item->hidden) { $attributes['class'] = 'dimmed_text'; } if (is_string($item->action) || empty($item->action) || ($item->type === navigation_node::TYPE_CATEGORY && empty($options['linkcategories']))) { $attributes['tabindex'] = '0'; //add tab support to span but still maintain character stream sequence. $content .= html_writer::tag('span', $content, $attributes); } else if ($item->action instanceof action_link) { //TODO: to be replaced with something else $link = $item->action; $link->text = $icon.$link->text; $link->attributes = array_merge($link->attributes, $attributes); $content = $this->output->render($link); $linkrendered = true; } else if ($item->action instanceof moodle_url) { $content = html_writer::link($item->action, $content, $attributes); } // this applies to the li item which contains all child lists too $liclasses = array($item->get_css_type(), 'depth_'.$depth); $liexpandable = array(); if ($item->has_children() && (!$item->forceopen || $item->collapse)) { $liclasses[] = 'collapsed'; } if ($isbranch) { $liclasses[] = 'contains_branch'; $liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true"); } else if ($hasicon) { $liclasses[] = 'item_with_icon'; } if ($item->isactive === true) { $liclasses[] = 'current_branch'; } $liattr = array('class' => join(' ',$liclasses)) + $liexpandable; // class attribute on the div item which only contains the item content $divclasses = array('tree_item'); if ($isbranch) { $divclasses[] = 'branch'; } else { $divclasses[] = 'leaf'; } if ($hasicon) { $divclasses[] = 'hasicon'; } if (!empty($item->classes) && count($item->classes)>0) { $divclasses[] = join(' ', $item->classes); } $divattr = array('class'=>join(' ', $divclasses)); if (!empty($item->id)) { $divattr['id'] = $item->id; } $content = "<a href=\"javascript:toggle('moreheight')\">" . html_writer::tag('p', $content, $divattr); //$content = html_writer::tag('p', $content, $divattr); if ($isexpandable) { $content .= $this->navigation_node($item->children, array(), $expansionlimit, $options, $depth+1); } $content .= "</a>"; if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) { $content = html_writer::empty_tag('hr') . $content; } $content = html_writer::tag('li', $content, $liattr); $lis[] = $content; } if (count($lis)) { return html_writer::tag('ul', implode("\n", $lis), $attrs); } else { return ''; } } }


Do not put a closing php tag on this file.

Lastly, in your Joomla theme find your index.php and right above where the main content (the iframe) gets called add this:
Code:
<script> function alertsize(pixels){ pixels+=32; //added to compensate for scroll bar document.getElementById('blockrandom').style.height=pixels+"px"; } </script>

Please note: In the Joomdle Configuration settings turn Autoheight off and leave scrollbars to Auto.

Yes, I realize this over 2 months old however...

Please Log in or Create an account to join the conversation.

More
13 years 2 months ago #4 by Chris
.... however, this is fantastic.

Thanks for sharing.

Please Log in or Create an account to join the conversation.