University of Oregon

Updated views to speed up admin pages

Commented out recordCount function in feedback and site_migration_list views.

< ?php
/* ### 11-5-12 This function is running slow and causing page load slowdowns. Commenting out for now. Vid
function recordCount($viewName,$displayName){
    $view = views_get_view($viewName);
    $view->execute_display($displayName);
    return count($view->result);
}
//get the record count:
//ex: $totalCount=recordCount('feedback','attachment_1');

(more…)

Updated the 'featured nodes' view for each book

I created a new block display in our frontpage_book_section view to display a more customized output.
Previously we had boxes with each ‘promoted’ node showing the title, teaser and ‘Read more’ link.

That worked fine in most cases but when we had a node with no teaser or body content those boxes were empty.
So I created a new block display that replicates the previous node output and also supports this ‘no teaser’ case.
When the view encounters a node without teaser content it displays all the ‘child links’ for that node instead. Which works great. The primary scenario where we have no teaser are ‘link pages’.
There are still cases where some users want to deliberately keep their featured boxes blank, even when there’s no content and in that case they can add an empty teaser to the body and the child links wont show up.

Here’s an example of the new featured boxes:
The current featured blocks don't have any blank cells

The bottom right box used to contain only the node title and left an empty impression on the user and now it’s displaying the child links.

Technical stuff:
That was done with Customfield: PHP code. I added some php to test for an empty teaser and call another view displaying the child links if need be.
Here’s the code:

node_revisions_teaser == ""){
  print views_embed_view('frontpage_book_section', 'attachment_1', $data->nid);
}
?>

It works great.

Added new styles to node titles and background image

I updated the styles on the hr site today. Removing the box around the page title and lightening the background image.

Before:
Screen shot before new styles
After:
Screen shot after new styles

Drupal 6 – Theming search results to remove the cruft…

The default search page output contains an ‘info’ line below each result. This line contains the Author name – content type – last updated date – # comments – # attachments.

I wanted to hide most of these.
I have several contributors to the hr web site who maintain data for other folks so the default output on the search results page wasn’t ideal for us.
So displaying the name of the user who maintains the content but not the knowledgeable contact isn’t helpful. In addition, our audience doesn’t know what a ‘book page’ is. Lastly, displaying “0 attachments” or “0 comments” isn’t very helpful. Especially considering that comments are turned of on most of our pages.

So I set out to theme the search results. To do so I did a quick search on drupal.org and found that I need a local copy of /modules/search/search-result.tpl.php in my theme directory. From there I could override the search result output.

Here’s what I added above the output of the page:

 $info_split_value){
    if($info_split_value == "0 comments" || $info_split_value == "0 attachments"){
      unset($info_split[$info_split_key]);
    }//end if
  }//end for each

   #update the info string to hide user and content type
  //remove Author
  unset($info_split['user']);
  //remove Node type
  unset($info_split['type']);
  //rebuild the info string
  $info = implode(' - ', $info_split);?>

I essentially replaced the info line with updated data removing the cruft as it were.
The last line

$info = implode(' - ', $info_split);

I pulled from the search.module code.
Now our search results are clean.

Installed a new admin menu

I moved the administrative menu out of the body of the site today. Putting it in a flyout menu in the upper left hand corner of the site. image of menu icon.
When opening the menu you’ll see your standard options the the list below.
image of open admin menu

I think this is an improvement and will help separate administrative items from content.

Updated administration theme

I updated the Admin theme so things will look a little different now.
The old theme has some conflicts in the code that is causing drupal to erase any former page urls… this is a bad thing. Changing the theme fixes that problem, while I’m testing for the cause.

Used jQuery to add a header for a group of courses

We had a group of courses for Take our Daughter and Sons to Work Day added to Making Tracks that all used the abbreviation of the name in their title: TODSTWD. They didn’t spell out the event name anywhere. So I added a jQuery script to the header that prepended the listing with the full title.
I limited this to course listing pages and confined it to a date range so it stopped running after the event.

Here’s a screenshot of the course list summary with out the jQuery header (before):

And here’s a screenshot of the course list summary with the jQuery header (after):

It also runs on the indiv. course details page.

Here’s the code:

&lt;?php
if(strtotime(date(&#039;Y-m-d&#039;)) &lt;= strtotime(date(&#039;2011-4-29&#039;))){ //display until 4-29-11
	$todstwd_script = &lt;&lt;&lt;javascript
	/* ########## Add TODSWD JS ########## */
	Drupal.behaviors.testBehavior=function(context){
		//run only if there is a context var
		if(typeof context !== &#039;undefined&#039;){
			/*
			Check the type of the context var and type. Process if context = [object HTMLDocument]
			Note: when context == [object HTMLDocument] then this is page load. You may want some script to run only on page load. Some not and some all the time.
			*/
			if(window.location.href.search(/course_view|course_list/)!==-1){
				$(&#039;.courseSummary h3 a&#039;).each(function(){
					if($(this).text().search(/TODSTWD/)!==-1){
						$(this).parent().parent().prepend(&#039;<h2 class="todstwd" style="color:#006600">Take Our Daughters and Sons To Work Day - 4-28-2011</h2>');
					}
				});

				$('#t_content h2').each(function(){
					if($(this).text().search(/TODSTWD/)!==-1){
						if(!$('#todstwd').length){
							$('#main').prepend('<h1 id="todstwd" style="color:#006600">Take Our Daughters and Sons To Work Day - 4-28-2011</h1>');
						}
					}
				});
			} //end if(window.location.href.search(/course_view|course_list/)!==-1){
		} //end if(typeof context !== 'undefined'){
	} //end Drupal.behaviors.testBehavior=function(context){
	/* ########## end Add JS ########## */
JAVASCRIPT;
	drupal_add_js($todstwd_script, 'inline');
}
?&gt;

Here’s a link:
Making Tracks | Organizational Development and Training ODT.

Added jQuery browser check for ODT and Skillport eLearning

I noticed a mac user getting frustrated when trying to log in to the eLearning site the other day.
The log in process was hung up on the loading screen for a few minutes:

I pointed out that it said ‘click here’ if it doesn’t load after 40 seconds but I realize that’s not very helpful.
It turns out they were using Firefox, which isn’t one of the supported browsers.

We do have the browser compatibility information on the page but that content is collapsed. So the user would have to look for it.
So I decided to add some browser compatibility tests and display a message to mac / firefox users to save them some trouble.
(more…)

OUS updates site and broken links

We’ve come across a few broken OUS site links recently and I wanted to pass on a fix.

Here’s an example:
The IT Performance Appraisal Instructions were formerly at:
http://www.ous.edu/dept/hr/files/Instructions.PDF

That link no longer works you can still find the file at their old site located at:
http://former.ous.edu/dept/hr/files/Instructions.PDF

You’ll notice that they replaced the ‘www’ with ‘former’ for their old site.

I ran a report to find any more broken OUS links on our site and found 10 more.
Other departments may encounter the same issue, so feel free to pass this on.

Php on UO Shell the bare minimum

I wanted to redirect a shell site to a new WPMU site on the UO’s Web Site Lite setup. http://sites.uoregon.edu/. Web Site Lite is great, but it has limitations. Since I wanted to redirect all the old links to the new site I set up a .htaccess file that bounces all requests from the old site to the new site.
To do just that I could use:

Redirect 301 /~oa/ http://oa.uoregon.edu/ #works but I'd like to remove .php and .html

But I wanted to remove the file extensions before redirecting.
For that I needed to use Mod Rewrite. Which means I needed to enable php on shell.
There used to be a post: Easy PHP on shell by Tristan but that page is down so I looked at my other domain on shell and it turns out, all I needed to do is put a php.cgi file in the public_html folder and add some lines to the top of my .htaccess file. Now the mod_rewrite script can run! (more…)