code, tips

Hiding PHPSESSID

I’ve built GlitterPony Magazine’s website so that it is dynamic. All I need to do is put the poems into the database fill in a field or two and I’ve got a functioning website. Of course the site is written in strict xhtml so that I can have a new look to each issue simply through modifying the CSS.

This saves me a lot of time since I can focus on the design aspects and ignore most of the tedious stuff. In fact I’m completely satisfied with this solution, I’ve even written the rewrite rules so that our URL’s all look pretty and are SEO’ed (Search Engine Optimized). The thing I am not satisfied with is that under certain circumstances a vistor would get a url that has something like ?PHPSESSID=5ab080e5cff5dc130f9bec234b stuck to the end of it. Boy is that ugly. It also hurts our ranking in search engines. But there is a fix and it is very simple.

All you need to do is add php_flag session.use_trans_sid off to the .htaccess file and bang! You got clean urls. Of course if you’d like you can add ini_set('session.use_trans_sid', false); to your php files, but why add that to all your files when you can add one line to your .htaccess file?

Standard
design, tips

Using <object> in Internet Explorer

As a web designer I hate Internet Explorer. Microsoft often makes their own rules despite there being rules in place already. I will say however that IE is getting better at following standards with each new version of its browser. The Big Problem™ is that sometimes IE interferes with a page remaining valid XHTML. There is a workaround for almost all of IE quirks, but it is often a long treacherous road to get there, and sometimes the fix is worse than the problem.

One way IE makes life hard is when a person needs to embed a webpage inside a webpage. Admittedly this should almost never happen because it is usually a bad idea. However, sometimes it is a good idea. The only time I’ve found it useful is in my web chess program. It is a good use because I require two separate elements to refresh at different intervals. Also, by limiting what refreshes it cuts down on page load and makes it so the main page never has the refresh blink (that second of white before things load in the browser).

Until now I’ve been using the <iframe> element to embed those pages because it seemed to be the only cross-browser solution. Today I discovered that someone took the long treacherous road and found a way to use the <object> element. The key is the classid:

classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13"

To learn more about using the element and making it work in IE read Brad Wrights discussion of the technique.

update: using the classid above breaks objects in FireFox 3 beta 5

Standard
design, wordpress

A Temporary Fix to Keep WordPress XHTML Friendly

Today I discovered two bugs in wordpress that keep it from being valid xhtml. They don’t happen in all occasion, but I was lucky enough to hit both with a project I was working on.

The first bug happens when you are using the links widget and have more than one category of links. What you get is multiple items marked with the same id. That is a no-no. Fortunately a kind person offered a fix right in the comments of the bug report.

Here’s a stupid simple fix. Add this right before the call to wp_list_bookmarks() in [widgets.php]:
$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);

The second bug is when the Archives widget is used and the “Display as a drop down” option is checked. The problem is that it uses “onChange” when it should use “onchange.” To fix this just do a search & replace in the widgets.php file.

I love WordPress, and I am glad that these fixes were easy, I hope that they (along with some of the other xhtml issues) get sorted out in the next release. If they don’t you’ll have to reapply these changes every update until they do.

Standard
code, technology, wordpress

XAlign, A TinyMCE Fix for WordPress

It’s bothered me that TinyMCE, WordPress’ default rich text editor, uses the align attribute. For example if you want to center some text and use TinyMCE you’ll get code that looks like this:

<p align=”center”>My centered text</p>

Why is that a problem? Here’s the list

  1. It is not valid strict xhtml
  2. It is deprecated transitional xhtml
  3. It does not function as expected across browsers in all cases

Anyone writing new code should aim to have valid strict xhtml. Why? Because strict code will offer a better experience for everyone across browsers, it will be easier to update, and it is more future-proof (though nothing is 100% future proof). Hopefully WordPress will come up with a built-in solution soon and render this plugin pointless, but until then this works.

Download

Standard