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 …

Three Good Things

Three Good Things: Building and deploying a project with Laravel

David Nash laravel, linux, mysql, php 1 Comment

What do developers do in their spare time? Code! Three Good Things is a little app that I started over the holidays, and have been working on in my spare time. During the Christmas/New Year holiday period I read Flourish: A Visionary New Understanding of Happiness and Well-being, by Dr Martin Seligman. In it he describes an exercise called “What-Went-Well” (or “Three Blessings”). The idea is, every night you write three good things that happened in the last 24 hours, and why they happened. I thought it would be a good idea for an app, so I set to work. It was a …

Display WooCommerce category description and custom category titles

WooCommerce category description and custom title

David Nash woocommerce, wordpress 0 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 …

Git: How to create a repository on a web server

David Nash bash, linux 0 Comments

I’m writing this mainly for my own reference. I found it very difficult to find instructions on using git for what I wanted. The scenario: I have a web server (example.com), which I can ssh into. It has a website running on /var/www/website/. I want to create a git repo for it, and then from my development machine (devmachine) clone that repo, make changes, and when I’m happy push them to the web server. I already have ssh keys installed so I can ssh from devmachine to example.com. On both example.com and devmachine I have a user david who is …

Link WP Ultimate Recipe ingredients to WooCommerce products

David Nash woocommerce, wordpress 3 Comments

WP Ultimate Recipe is probably the best WordPress plugin for creating recipes. It has one major drawback – it’s not possible to link to WooCommerce products on your site. This seems like a feature that online food retailers would want. The WP Ultimate Recipe premium plugin adds the ability to add a link to a product ingredient. This is great if the store doesn’t have many products, or you want to link off-site. What I wanted was to let the site admin search their WooCommerce products without having to jump to a different tab to find the link. First, install WooCommerce, WP Ultimate …

Aw Yiss! WooCommerce Breadcrumbs

WooCommerce Breadcrumbs – Control Product Categories

David Nash woocommerce, wordpress 2 Comments

WooCommerce breadcrumbs will show the first category it finds that a product is in, no matter how you got to it. This makes sense, as breadcrumbs should more be about categories than browser history. Unfortunately if that category is alphabetically earlier, it will display that – no matter how many levels of categories it is deep. It makes more sense to me to show the shortest path of categories to the product, which is what this tutorial is about. I’m going to assume you’re using a child theme for this. If you’re not, sorry – you’ll need to go and set …

Display WooCommerce category description and custom category titles

Woocommerce: Show attributes on single product page

David Nash woocommerce, wordpress 13 Comments

I’ve been working on a large Woocommerce site recently. Woocommerce gets updated regularly and unfortunately the documentation doesn’t always cover the new features. Generally when I come across a new problem I ask Google. It’s easier to adapt code than it is to write it from scratch. To be honest, I find the attribute system a little confusing. I came across this Stack Overflow article, which helped. Then I realised there was a much easier way. Step 1 – Create a Woocommerce action Edit functions.php in your child theme. Add the following:

Reload the page for a product. You should now …

Pretty print fractions as HTML entities using PHP

David Nash code, html, php 1 Comment

I used this code in a WordPress site but it’s pure HTML. I wanted to take a string, for example “3/4” and convert it to a HTML entity ¾. When there’s no HTML entity I still wanted it to look nice, using <sup> and <sub> for the numerator and denominator respectively. I couldn’t find anything on the web that I could copy and paste so I wrote it myself. Here’s what I came up with:

It’s pretty straight forward. First we check that the string is of the form X/Y. We put the X and Y into an array, …