Customizing a Symfony layout with property settings via slots

Ever wanted to have a layout in Symfony that allowed a template to pass it information about what to display in a more structured manner than slots allow? Well, here’s how to do it. You still need to use slots to avoid the caching issues described in http://trac.symfony-project.org/wiki/Symfony11LayoutUpgrade, but it is pretty easy to do once you know how.

For example, you have to basic page designs using the same layout, you just need to set a css class on the body element so your stylesheet knows which design to display. The default design is with no css class set and the alternate design is in effect when the css class is set to “alternate”.

You would normally do this with a simple slot in your layout:

<body class="<?php if(has_slot('bodyClass')) { include_slot('bodyClass'); } ?>">

Then, for any view that needs the alternate design, put this in its template:

<?php slot('bodyClass') ?>alternate<?php end_slot() ?>

Now, this will work well for a while—until you want to change the class name from alternate to something else and you realize that you now have 50 pages to go edit. Is there a way to avoid this maintenance horror?

Read More »

Leave a comment

Tip: How to remove a user from Google AdSense

If you want to remove a user from the My Account -> Account Access screen of AdSense and there are no Actions available, you likely have a linked AdWords account and will need to do it there. Go to the My Account -> Access screen of AdWords and click on the Terminate access link next to the user you want to remove. This will remove them from both AdWords and AdSense.

Leave a comment

Ruby on Rails development with Eclipse and RadRails

To successfully install Aptana RadRails into Eclipse without installing the full Aptana Studio:

Read More »

Leave a comment

The Browser Wars and UI Testing

I just did something that I’ve been putting off for a long time: I switched to FireFox. I’d been a longtime Opera fan and I kept hoping that the sites I use would start to support it better, but that didn’t happen and Internet Explorer 7 came out with tabbed browsing, so I couldn’t justify sticking with it. I knew there was also FireFox, but I didn’t want to put the time into learning a new interface.

Read More »

Leave a comment

How to get URL rewriting to work with ASP.Net 2.0 Themes and form post-backs

Back in February, Scott Guthrie posted an article on URL rewriting with ASP.Net. Towards the end of the article there is a section on how to handle form post backs by sub classing HtmlForm (for ASP.Net 1.0 and 1.1) or by using a Control Adapter (for ASP.Net 2.0).

That seemed like a lot of work to get a viable solution so I decided to try and find a simpler solution before I “bit the bullet”. Additionally, ASP.Net 2.0 Themes do not always work with URL Rewriting and the article did not provide a solution.

The solution is to use the Application PostMapRequestHandler event to rewrite back to the original URL after the request has been mapped to its handler.

Read More »

Leave a comment

Easy way to get FCKEditor to work inside an ASP.Net AJAX UpdatePanel

The Problem

I had a MultiLine TextBox inside an UpdatePanel and I wanted that TextBox to have rich editing capabilities so I chose FCKEditor. But, now when I do a partial PostBack, the TextBox doesnt retain it value.

An Initial Solution

So, I searched for a solution to this problem and found this post, but it seemed like more of a hack than I prefer.

Read More »

Leave a comment

How to enable Umbraco directory URLs without needing a wildcard mapping in IIS

If for some reason you cannot create an wildcard mapping to ASP.net in IIS, but would still like to have directory URLs in Umbraco there is another way. You can use ISAPI_rewrite (or a similiar tool) to rewrite requests to an extension that is handled by ASP.net. Here are the ISAPI_rewrite rules I use to accomplish this for JLCoady.net:

Read More »

Leave a comment

Loose expectations with NMock2

NMock2 will have a verification failure if all expected calls are not made and if any unexpected calls are made. That last bit can make writing test code rather tedious.

I have a presenter and I’m testing its normal path using a bunch of calls like the following:

...
Expect.Once.On(view).GetProperty("Name").Will(Return.Value("Widget"));
Expect.Once.On(view).GetProperty("Quantity").Will(Return.Value(3));
Expect.Once.On(view).GetProperty("Price").Will(Return.Value(9.95m));
Expect.Once.On(view).Method("ShowTotal").With(29.85m);
...

That’s all good, but now I want to test some error conditions, exceptions, bad input, etc., but I dont want to repeat all the property test, especially considering the maintenance issues—if I add a new call to another property in my presenter, all my tests will fail because there was an unexpected call. It would be much nicer to only have to change one test instead of many. Not to mention that testing the same thing ten times is rather stinky.

Read More »

Leave a comment

Using asp.net syntax in an umbraco document template and in XSLT templates

I am about to embark on a project that will be using ASP.NET AJAX extensively, along with the ASP.NET AJAX Control Toolkit. I would love to be able to do the whole thing inside of Umbraco, but, as far as I know, the only way to use these controls is from within a macro.

For example (very simplified), I have a list of items that I want to display. Each item gets a delete button. I would like to put each item into an updatepanel and so when the delete button is clicked, the item simply disappears. There is no need to reload the entire page when we are just changing one small portion of it.

Right now, my options would be to put the entire list inside a macro or write all the ajax myself (which seems like a step backward).

Read More »

Leave a comment

Umbraco’s rich text editor is using my site’s styles

I am creating an Umbraco site with a document type that has rich text (my innovation here is astounding!) and everything was working great on my local. Then I upload it to the production server and the rich text editor now has a navy blue background with black text and is centered—editing is now very difficult. Since the site I am creating has a navy blue background I had an obvious culprit and a quick test by deleting the site’s style sheet confirmed my suspicions.

After tinkering for a while and do some searching, I have found out why this was happening only on the production site and how to fix it.

Read More »

Leave a comment