Custom Thumbnails Do Not Appear When the Associated URL is Aliased

chsoney - July 4, 2006 - 17:46
Project:Control Panel
Version:4.7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I am currently using the block feature of the controlpanel module for site navigation on a site that I am converting to Drupal. After a few changes to the CSS, I was able to make the control panel look like the original navigation panel. I setup the menu before the pages were created and, hence, had predefined addresses I wanted to use. For example, for a help desk link, I had the path be 'helpdesk'. I also followed the instructions to create custom icons by creating a directory called control panel in the top-levl directory of my theme. Hence, I had a png file called helpdesk.png. The image showed immediately. However, when I created a page that aliased to 'helpdesk', the image was replaced with the default image.

I am fairly comfortable with PHP and, therefore, decided to investigate the issue myself. In the function theme_controlpanel_panel_view, the code looks for the image by appending the path of the appropriate menu items. However, with my aliased helpdesk, the path was no longer 'helpdesk', but 'node/1'. Therefore, I created this external function

<?php
function _controlpanel_generate_aliases() {
 
$aliases = array();
 
$results = db_query("SELECT src, dst FROM {url_alias}");
  while (
$row = db_fetch_array($results) ) {
   
$aliases[$row['src']] = $row['dst'];
  }
  return
$aliases;
}
?>

I also added the follwing code to the function theme_controlpanel_panel_view after the variable $working_path is first assigned.

<?php
  $aliases
= _controlpanel_generate_aliases();
  if ( isset(
$aliases[$working_path]) ) {
   
$working_path = $aliases[$working_path];
  }
?>

A conditional expression would probably have been more appropriate. After I made these changes, the image came back. Although these changes worked, I have had experiences with changing components of a CMS only to find the latest upgrade will destroy my changes. Moreover, there may either be a more elegant way to make the changes or perhaps a reason why this change should not be implemented.

Also, I wrote this code from memory since I cannot access the actual code at this time. So, if there are any problems with the code that is why.

AttachmentSize
screenshot_24.png97.2 KB

#1

chsoney - July 5, 2006 - 15:13

After putting my solution in words, I realized that there is much simpler solution to the problem. I looked in path.inc and found the function drupal_get_path_alias which does what I want. It takes an internal path as input and either returns an alias or or the original path if no alias is found. Therefore, the few changes that I originally made can be boiled down to just one. When $working_path is being assigned change the line to

<?php
$working_path
= drupal_get_path_alias($menu_visible[$mid]['path']);
?>

Therefore, no functions have to be created and no lines of code added.

#2

der - September 22, 2008 - 01:08
Status:active» fixed

#3

Anonymous (not verified) - October 6, 2008 - 01:12
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.