Archive for category: problems & solutions

The title of this post says it all! I have been wracking my brain for weeks trying to get the latest recaptcha (v3) from Google to work on my PHP sites (no CMS) and I tried all these great tutorials and nothing worked. Google just never sent anything back.

I finally found a thread where one wonderful person posted this PSA that they needed to turn on allow_url_fopen in their php.ini file. I tried it and voila! Now all this code I thought was completely broken works perfectly. I simply has to pass on the great news! Hopefully this helps someone else.

php.ini
allow_url_fopen = On

Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

I’ve seen this far too many times on WordPress sites, and for a long time struggled with the solution.  I finally figured it out and since I use it without trouble every time now, I simply have to share.  While there are many things that could cause the error, in all the cases I’ve experienced, it’s been a problem with the owner of the WordPress files on the Apache server.  So the solution involves connecting to the site through SSH.  Navigate to your wordpress directory.

  1.  Find out who the web user is on your copy of apache by running this command: ps aux | egrep ‘(apache|httpd)’
    You should get a list of files and their owner, and the most common owner name will be what you want to use.  It’s probably something like ‘apache’ or ‘www-data’ or ‘root’, but for this purposes of this explanation, I will assume it is ‘www-data’.
  2. Assuming your wordpress installation is in an htdocs folder, the first thing you want to do is reset the ownership of all the wordpress files to this web user:
    chown -R www-data htdocs/
  3. Maybe not required, but you can also change the group ownership of all the wordpress files:
    chgrp -R www-data htdocs/
  4. And finally, give full privilege for the directory:
    chmod u+wrx htdocs/*

Hopefully you, like me, will now magically have back the ability to keep WordPress automatically updated again!

So, here’s the situation.  I have a bunch of images, and each image has a larger version and some rich text content to go with it, that needs to be opened in a modal window.  All the related content for each image sits within the page, so I need to use inline content.  I am also using Colorbox for the modal window.  I had a hellofva time finding an appropriate tutorial and example for this online.  A lot of people are trying to do similar things, but there’s either no solution or what they want isn’t close enough to what I’m trying to accomplish.  Every photo needs to have its own link AND still be in a prev/next slider once the modal opens.

After a lot of trial and error, I figured out how to do it.  So here goes:

THE HTML

For your links themselves:

  <a href="#preview1" class="preview">Preview 1</a>
  <a href="#preview2" class="preview">Preview 2</a>
  <a href="#preview2" class="preview">Preview 3</a>

For the inline content boxes:

<div style="display:none">
    <div id="preview1" rel="previewBox">
          <div>Awesome HTML Content</div>
    </div>
    <div id="preview2" rel="previewBox">
          <div>Awesome HTML Content</div>
    </div>
    <div id="preview2" rel="previewBox">
          <div>Awesome HTML Content</div>
    </div>
</div>

THE JAVASCRIPT

<script type="text/javascript">

  $(document).ready(function() {

    $(".preview").colorbox({
      open:false,
      inline:true,
      html: function() {
          var div = $(this).attr('href'); return $(div).html();
      },
      href: $(this).attr('href'),
      rel: 'previewBox'
    });

  });

</script>

Anyway, here’s hoping this saves someone some time! This was done successfully with Colorbox 1.3.17.2 and jQuery 1.4.1.

I’ve run across this problem many times in my career with WordPress – suddenly the page-edit.php screen or the page-new.php screen starts loading up blank. This is a very common problem that has a LOT of solutions. Deactivate plugins, deactivate your theme, and so on. But for the first time ever, this was not the problem for me.

After some creative sleuthing, I discovered that if I had less than 56 pages in the database the problem went away. This naturally led me to check PHP’s memory limit, and sure enough it was set to 16M! I also turned on errors and got this lovely note: “Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 58368 bytes) in /wp-admin/menu-header.php on line 84

So short story shorter, check your memory limit! 16M is pretty small for any website running off a database. Â I would just like to add that to the long list of things to check. Â Here’s a good article on increasing memory limit.

Pretty simple problem. I wanted to use the jCarousel plugin for jQuery to have a scrolling list of items, using the ‘circular’ wrap, where you never reach an end. See: circular carousel, but I also wanted to use Thickbox, so that if someone clicks on the image, it opens up a modal window with more information. Carousel already comes with an example that uses thickbox, but it’s not for the circular carousel, just the linear one. See: jCarousel with Thickbox 3. Since the code here is different, applying tb_init(item) doesn’t work.

I scoured the internet, and got extremely discouraged as all threads on this topic either end with someone saying “Forget it, I just gave up” or the dreaded no response. So, like all big problems, I slept on it and awoke with a brilliant and obvious solution: force it.

Assuming you’re already familar with the methods of Thickbox, take yourself to the jCarousel function mycarousel_getItemHTML. Within this is the code where you would expect to add class=”thickbox” on the a tag and get the magic results. This won’t work.  Instead of having this:

return '<a href="#TB_inline?height=155&width=300&inlineId=
hiddenModalContent" title="' + item.title + '">
<img src="' + item.url + '" width="75" height="75" border="0"
alt="' + item.title + '" /></a>';

I put in a force call to the Thickbox function that intiates the window onclick:

return ‘<a href=”#” onclick=”tb_show(‘‘ + item.title + ‘‘, ‘#TB_inline?height=155&width=300&inlineId=hiddenModalContent’,’false’); return false;“><img src=”‘ + item.url + ‘” border=”0″ alt=”‘ + item.title + ‘” width=”75″ height=”75″ /></a>’;

Let’s break that down:

tb_show
Thickbox function that opens a modal window, takes 3 arguments

'" + item.title + "'
Here we assign the first argument to be the title tag you assigned in mycarousel_itemList
This will also be what shows as the title in your thickbox window

'#TB_inline?height=650&width=600&inlineId=contentid'
We’ve taken the normal href code from the a tag and stuck it into the second argument of the tb_show call instead! This simply works the same way as putting it in the href does, it just skips a few steps.

false
Not sure, but just make it false :)

return false;
I’ve added this in to make sure the browser doesn’t try to go to your blank link, now that the href is empty. returning false; will keep the browser where it is and enable your viewers to see your modal window.

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.

I recently installed this text-based database user forum for a client using myUPB, my job was suppose to just be changing the template to match their current site. However, as the client started to use the software, we noticed some wonky things happening. Lost password e-mails never got sent, or, when they did, the included URL provided no host name. Just http://?request_ID=1&passcode=20076. Funky!

I did some research into the forum software and poked around the code a bit and found it was using $_SERVER[‘REQUEST_URI]; as well as $HTTP_HOST and other such fun server based variables. After a Google search of said keyword, I found this great blog post by David Walsh.

According to him, the problem could very likely be that the hosting server was IIS. I checked with the host, and bada-boom! IIS was indeed the problem. I implemented his code which retrieves $_SERVER[‘REQUEST_URI] in another way.

I’ll update this post as I work my way through all the other problems having this forum on IIS is causing.