Tag Archive for: drupal

Posts

Here’s a fun discovery I made last week!! Â In the past if I needed to test a website on the production server I just made a dev.domainname.com site, or I got an IP address to use for a month until it was ready to go live.

While working with a colleague on a website going live, he opted to use GoDaddy’s free preview service, previewdns.  The website we were testing was a PHP/Mysql/Apache on Linux server running off  Drupal 6.0.  A bunch of things in the admin went wonky.  All the collapsible menu features stopped working, so did the WYSIWYG.  We had countless issues with anything involving Javascript.  Imagine our consternation trying to figure out how so much could be different on a practically identical server!  Turns out, it’s previewdns’s fault.  Once moved over to the live domain name, all these issues were fixed.  Maybe next time I’ll just spend a buck on an IP address and be sure of what I’m seeing 🙂

I’m trying to find some articles that explain how and why previewdns is breaking everything – but only positive reviews exist so far! Â Spread the word! Let me know if you have had any issues or find any articles on how to deal with these problems.

I needed a way to display submenus on pages on a website built in Drupal 6. The menu system itself, built with Drupal Menu’s primary links, was three levels deep. So, a small snippet of the menu as an example would be:

About Us >
    Directors
    History
    Mission
Services >
    Pricing
    Administration
        Trusts
        Estates
    Special Needs

If someone is on the “History” page, I want a sub menu to appear on the left with all the other links that appear under “About”. Drupal has a module called Submenu Tree which comes with hardly any instructions, and didn’t seem to work. So after much digging around, I found a quick and simple solution using some Drupal functions and the template.php file.

In my theme’s template.php file I created a new function called Submenu() that looks like this:

<?php

function Submenu() {

$menu_theme = menu_navigation_links(“primary-links”,2);
$menu .= “<ul>”;

foreach ($menu_theme as $value) {
  $menu .= “<li>”;
  $menu .= l($value[‘title’],$value[‘href’]);
  $menu .= “</li>”;
}

$menu .= “</ul>”;
return $menu;
}

Then, in your page.tpl.php file, whereever you want the menus to appear, just do a print(Submenu()); and voi-la!!

The code explained:

$menu_theme = menu_navigation_links(“primary-links”,2);

This is a drupal function that will return an array of all the links relative to the current menu, the second argument, the ‘2’, says I want to see all the links for the 3rd level. If I was on the “Trusts” page, this would return an array with “Trusts” and “Estate” link information.

$menu .= l($value[‘title’],$value[‘href’]);

This is another Drupal function that creates an automatic link based off link text and a path URL. Both of these are made available to us from the array we got in $menu_theme.

This is a problem with TinyMCE 3.0. They don’t currently have align attribute working properly, so they’ve substituted float: left; to temporarily solve this problem. “float” is applied to the image using the “style” tag, but the base install on TinyMCE does not come with the option to add style attributes to images, so you have to add it into the list of usable tags using the ‘extended_valid_elements‘ settings.

Achieving this in Drupal is easy: go to the plugin_reg.php file which is located in your TinyMCE module directory. Find the line that says

$plugins['advimage']['extended_valid_elements'] = array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]');

and make sure you add |style to the very end, like so:

$plugins['advimage']['extended_valid_elements'] = array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]');

If you’re using TinyMCE with any other software, I suggest doing a search for ‘extended_valid_elements’ and see if you can find where it’s being defined for ‘img‘. It probably looks very similar to this everywhere.

Problem: I have a website running on a local MAMP install with Drupal and it’s working perfectly. I move the entire site, database and everything, over to a Network Solutions host. Everything looks fine, except when I log into the admin, I get an access denied error. The login works and it takes me to the admin area, but when I click around, I get pages with just content loaded that say access denied. No style sheets, no theming, but it is trying to pull in the content. Which means it’s accessing the database fine. It’s just having some sort of session problems.

Solution: Another one of those odd scenarios where it ends up being something totally simple and unexpected. The new server was using CGI instead of Apache, which, yes, will cause some problems. But this problem was actually related to the immense number of domain names associated with the account. There were about 5 or 6 domain names which all pointed to the same host. Drupal’s admin only lets you resolve to one domain name, and it was picking the first one it found alphabetically. Because the site we were trying to load started with a T and the first domain name on the list started with an E, going to the admin area from the T page caused an error. Going from the E domain was smooth sailing.

I still consider this topic open. What if we really want to be able to do everything from the T domain? Why does Drupal’s admin care what domain you’re reading from? Maybe we can find some answers here.