Thursday, September 18, 2014

There's a first time for...

...editing and problem-solving within someone else's code. My first time with this was a few days ago!

On a quick visit to my brother and his family, my sister-in-law - I'll call her the client here - asked, "Hey, are you pretty good with HTML?" (Spoiler alert: HTML wasn't really the issue, but yes, yes, I am.)

She needed help with her job's website, which was built and maintained through CMS Made Simple. There was some content she needed to update, and when she tried it herself, she got an error and wasn't sure how to fix it. So that morning, while I wasn't playing with my niece, I was working out this puzzle.


The puzzle

Client's request: Add 1 line of content to 3 different pages of a website
Error: After adding content and trying to submit the changes (which did not include changes to the Name field of this file), an error comes up saying that the Name field is not in the correct format.

So, this seemed like a pretty simple problem. The requirements for the Name field were that they not have spaces or invalid characters; the files, as they had been operating, were named something like "Contact Landing - A," "Contact Landing - B," and "Contact Landing - C." I changed the names* to be in the correct format like so: "ContactLandingA." So that should work, right?

But then, upon saving the changes and refreshing the page, the section within the file disappeared all together. After spending some time trying different things, I decided to take a break and come back to it. And that's when it came to me - of course, since I changed the name of the file, I needed to update the file name wherever it was being referenced.

The next puzzle was to find where it was being referenced. The file I changed was nested within a global content section, and after some investigation, I discovered that it was referenced within a file in the templates directory. The format for referencing the file was one I hadn't seen before and didn't fully understand. I'm not even completely sure what language it was in - maybe PHP? There were curly braces, an "=" and a "$" and some files names, all arranged in a way I didn't quite understand. But I tried some things out, replacing a file name where I thought it made sense - and it worked!!

*Actually, I only changed the name of file A, but left file B as it was so that I would have a comparison - as far as I could tell, there was no version control system here, and I didn't want to break anything. I'm glad I did this - it was helpful as I went along to compare what the code was like before the change, and what the code with the error was. 


The prize

My reward for figuring all this out was, of course, my sister-in-law's thanks, but the best part was how accomplished I felt once I had solved the puzzle!! I have been learning to code for about 3 months now and I'm getting the hang of doing the codecademy.com tutorials, and I've been a little worried about what it would be like to stare down pages of someone- (or ones) else's code and figure out what was going on. With this small, but still sweet, success, I am more confident about jumping into mysterious code. 

Thanks for reading! Tell me about your first experiences working with someone else's code in the comments!

No comments:

Post a Comment