Archive for March, 2008

Open New Windows Without A Target

Tuesday, March 25th, 2008

I wanted to document this solution to a small, but irritating issue I have been having. As I make efforts to improve the standards compliance of the code my company turns out I often utlilize this blog to as a proving ground. As you can see in the right hand column I maintain this site as validating to XHTML 1.0 Strict standards. This often leaves me to abandon tried and true solutions that simply will not pass validation. It also pushes me to find new, standards compliant solutions to these issues.

One of the simplest matters I have had is in finding an acceptable method for opening links into new windows. Since the use of target is not an acceptable attribute within Strict standards nomenclature I have been left scratching my head for lack of a good solution.

Resolution

Thank You, SitepointThe resolution is at hand and it is documented in this Sitepoint article. This is a simple, JavaScript answer to this little puzzle. Although I am happy to have this solved, I really appreciate the attention to detail as the Sitepoint writer explains why this is a truly standards compliant solution, particularly as it relates to the governing Document Object Model (DOM).

It should be noted that this is in place within the links of this article.

Modx Template Variables for JavaScript Calls

Tuesday, March 25th, 2008

I have spent a lot of hours over the last couple of weeks really digging into Modx. I keep finding myself pleasantly surprised at how flexible and easy to use it is. I have also discovered that their forums are very well supported and often receive answers within minutes of posting my questions.

I have recently been delving into the use of Modx Template Variables (TV) to create a surprising level of flexibility within the framework. My rudimentary efforts began with a desire to improve a web page featuring a google map with landmarks. I built the page about a year ago and have recently redeveloped the back end of the site. As I have worked on the site I have incorporated a relative font resizing feature for improved accessibility but found that my map was excluded from the upgraded functionality. My original solution, in Modx, was to provide the content code through an iframe. The map was not under the direct control of my CSS documents.

As I began to rework the page I realized that if I went with a more traditional solution I would have to create the JavaScript calls for the map functions from within the header of the document. As this is a pretty involved map just the JavaScript call was 230 lines of code. This was really too much weight to place on the site header and was the antithesis of my recent efforts to improve accessibility and decrease overall page coding.

Example: Template VariableAgain, Modx and the forum provided an elegant answer. I created a TV using a Textarea input type and an @INHERIT Default Value (@BINDINGS). Next I place the new TV ([*newTV*]) into my header.

All that was left was to return to the page in question and insert my JavaScript into the newly created TV text area for that page.

Once the page was completed I quickly realized that this technique could be used for similiar pages, like our contact forms which require a large amount of coding in the <head> tag as well, but that is specific to a single page within a common page template.

I have also been reading about further uses of the @INHERIT bindings to take advantage of the hierarchical structure of the document tree to affect sectional changes when placed in a parent document. Although I haven’t tried this to date, you can see an example on the page from the link above.

As I have been broadening my investigations for Modx resources I have also found this YouTube link which might provide some useful information to anyone evaluating this CMS.

SEO, URL’s, and Modx

Thursday, March 13th, 2008

After looking over the SEOmoz article 11 Best Practices for URL’s I began thinking it might be beneficial to record my recent experiences with Modx. Particularly as it related to quick and easy creation of SEO friendly URL’s.

ModxBy utilizing the .htaccess file packaged with Modx to harness the power of Apache’s mod_rewrite engine, URL naming flexibility is within reach in minutes. All you have to do is uncomment the appropriate lines in the .htaccess file and upload it to the root directory of your install. The rest is just a matter of a few simple configuration tweaks inside of the CMS control panel.

Go to Tools->Configuration->Friendly URL’s and choose ‘Yes’. Also don’t forget to choose your appropriate suffix (.htm, .html, .php, etc.) that will be applied to all URL’s generated by the CMS.

Next within the document editor of any page within your site type the URL name within the ‘Document Alias’ field. This will be applied, along with the suffix, as the URL name.

That’s it, it’s that easy to create well formed, SEO friendly URL’s within a dynamic content management system. As I have been learning the ins and outs of Modx over the past few weeks I have found it is one of the more versatile tools I have come across as a developer. It is not a CMS for everyman due to it’s relative complexity, but it is just what the doctor ordered for a commercial developer in desperate need of a robust CMS system.