overriding the assignment view in the theme

overriding the assignment view in the theme

dan attwood -
回帖数:3

Currently my theme uses a 3 column layout of pre - content- post.

 

This works fine form most of the site. However in the assignments grid view the content is squished to much to be useful. I want to be able to remove or move the post column in this view.

Am I able to this by creating a new layout in themename/layout and then calling the new view in the $theme->layouts array? Like:

<code>

$THEME->layouts = array(

   'assign' => array(
   'file' => 'columns3-mylayout.php',
   'regions' => array('side-pre', 'side-post', 'footer-left', 'footer-middle', 'footer-right'),
   'defaultregion' => 'side-post',
   ),

);

</code>

 

if not how can I do this?

 

 

 

回复dan attwood

Re: overriding the assignment view in the theme

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Yes it should work.  Or change the layout file for 'assign' to columns2.php and remove 'side-post', set default region to 'side-pre'.

回复Gareth J Barnard

Re: overriding the assignment view in the theme

dan attwood -

for some reason that really doesn't want to work. I thinks it's because the assign view is int he mod folder.

 

I've ended up solving the problem with the following javascript (I'm using the essential theme):

  $(document).ready(function() {
  // This is to change the page layout on the assignment grid page to give extra space and fit more columns in
   var url = location.pathname;
   if("url:contains('mod/assign/view.php')"){
   $('#block-region-side-post').css('display', 'none');
   $("#region-bs-main-and-pre").removeClass("span10");
   $("#region-bs-main-and-pre").addClass("span12");
   $("#block-region-side-pre").removeClass("span3");
   $("#block-region-side-pre").addClass("span2");
   $("#region-main-essentialmkc3").removeClass("span9");
   $("#region-main-essentialmkc3").addClass("span10");
   };
});

回复dan attwood

Re: overriding the assignment view in the theme

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Hi Dan,

With respect I just think you are doing it wrong.  Resorting to JS is not the solution in this case to remove 'side-post'.  Just because the assign view.php file is in the mod folder does not mean that the theme cannot adapt it.

Where did you get the 'assign' layout from?  Given that it is not listed on http://docs.moodle.org/dev/Themes_overview#The_different_layouts_as_of_21st_April_2013.  I did not spot it earlier as I thought you were adapting what was already there.  If you want to know what layout is used on which page, then turn on 'Show page information' under debugging: http://docs.moodle.org/26/en/admin/setting/debugging#Show_page_information.

Therefore you just need to edit the theme's config.php file and change the 'incourse' layout to:

   'incourse' => array(
   'file' => 'columns2.php',
   'regions' => array('side-pre', 'footer-left', 'footer-middle', 'footer-right'),
   'defaultregion' => 'side-pre'
   ),

Gareth