Mark My Words - built with Laravel and Vue.js

Laravel and Vue.js: creating the Mark My Words web app – Part 3

David Nash laravel, vue.js 0 Comments

If you’d like to start from the beginning, please go back to Part 1 – which covers installing Laravel, connecting to the Oxford Dictionary API, and displaying the results to the user. Then you can move on to Part 2, where I covered creating the database with Laravel’s artisan commands, connecting the back and front ends, and saving the word/definitions for the user. At the end of Part 2, we’d saved the user’s word/definition to their list. So let’s move on to displaying that list, and allowing the user to delete the word. Getting all saved words from Laravel In …

Mark My Words - built with Laravel and Vue.js

Laravel and Vue.js: creating the Mark My Words web app – Part 2

David Nash laravel, vue.js 2 Comments

If you missed Part 1, you can view it here. Part 1 covers installing Laravel and setting up Vue.js to search for definitions from the Oxford Dictionary API. It then displays them to the user. Now we want to let the user save their word and a definition. While there might be multiple definitions for a word, I want to save the definition in the sense I came across it. The user can search for the word again to add a separate definition if they like. Using Laravel to set up the database Initially I thought that I’d just use a …

Mark My Words - built with Laravel and Vue.js

Laravel and Vue.js: creating the Mark My Words web app – Part 1

David Nash laravel, vue.js 2 Comments

After having lots of fun using Laravel to build Three Good Things, I naturally started looking for other fun projects I could build. I don’t really watch TV — I prefer to read. At the start of the year I was thinking about new year’s resolutions and decided that whenever I read a word I didn’t know, I would write it down. I quickly discovered that looking up a word and it’s definition was a fairly major interruption to whatever I was reading, especially using mobile to copy+paste into a Google Keep note. It seemed like a fairly simple thing …

Display WooCommerce category description and custom category titles

WooCommerce category description and custom title

David Nash woocommerce, wordpress 2 Comments

The WooCommerce category description is a good way to increase usability and improve SEO on your site. We can also show a custom category title which is a little more descriptive. To do this, it’s good practise to start with something easy, get that working, and then build from there. Show the WooCommerce category description In the child theme, if it doesn’t already exist, create a woocommerce/ directory. Copy the template file from wp-content/plugins/woocommerce/templates/archive-product.php  to wp-content/themes/[your-child-theme]/woocommerce/archive-product.php. Now we can edit that without changing any plugin files directly (which could get replaced on the next update). In WooCommerce 2.0.0+, towards the top of …

How to create a select element option (drop-down) menu in the WordPress Theme Customizer

David Nash css, php, wordpress 2 Comments

I’m working on a project that requires the same basic theme for two companies that are both under the same group. The only real difference is the logo and theme colours. Instead of creating two separate themes and having to maintain them separately I used WordPress “customize_register” action in the theme’s functions.php. The official docs are here and very long and confusing. https://codex.wordpress.org/Theme_Customization_API WordPress provides some basic types like a text field, image upload and colour picker, but no select menu: https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control Here’s the code I’m using to create a select element with two options (in the theme’s functions.php file): …

Why I love anonymous functions in PHP 5.3+ for WordPress functions.php

David Nash php, wordpress 0 Comments

From PHP 5.3, we can now use anonymous functions. If you write jQuery javascript, you probably use these all the time, even if you’re not aware of it:

Here we’re calling the ready function and passing it an anonymous function. We could also do:

(Let’s ignore the “$” for now). It’s the same with PHP. We don’t have to name functions – they can be anonymous. Why do I love it for WordPress? Adding actions and filters always seemed so clunky. We write a do_my_thing() function and then call add_action(), passing the hook and the function name. The …

WordPress: show sticky posts, then show all other posts in one loop

David Nash php, wordpress 1 Comment

This is something that’s driven me a little insane for a while. WordPress posts can be marked “sticky”, which is awesome. But if you’re not using it on the home page it just doesn’t work. In the past I’ve given up and resorted to doing two “The Loop”s, one with just stickies and one without. But there’s an easier way. In your themes functions.php, do this:

There’s nothing else to chage – the filter just steps in and takes care of it! Based on this answer http://wordpress.stackexchange.com/a/87788, which I only needed to minimally modify to get working. This uses …

Using the pure white light of PHP to pierce the dark miasma of .NET forms

David Nash php 0 Comments

Coming from a solid open source/PHP background, any interaction I have with .NET usually leaves me wondering just how those guys at Microsoft were able to stay that high for that long. Maybe they’d made a wish on a cursed monkey hand where they wanted the web to be stateful. Or made a pact with the devil. One of those “always backfires” kind of deals, like when you wish for hot babes and they’re literally one million degrees centigrade. I recently created an application that would interact with a .NET search form. I looked into the face of insanity and …

WordPress: Limit Archives to Single Category

David Nash mysql, php, wordpress 9 Comments

Late yesterday afternoon a client asked if I could look at a business’s WordPress installation. They had posts in several categories but only wanted to show the “Latest News” posts in the archives. WordPress is designed around blog posts, whereas I find that many business or company sites are designed around pages (eg About Us, Contact Us) – and don’t use WordPress’ powerful blogging tools on the front page. My site is an example – the content on the home page doesn’t change that much. This means that many of the solutions are also geared around blog-post design. While searching …

Using PHP variables that contain hyphens

David Nash php 2 Comments

This took me a little while to work out. I’m using PHP5’s SimpleXML to parse XML into a PHP object. The XML has entries like <HELLO-THERE>. But you can’t use $xml->HELLO-THERE because it reads the hyphen as a minus. Instead, use $xml->{“HELLO-THERE”} Easy!