Use excerpt blocks for all posts
This commit is contained in:
parent
a813a83317
commit
6ad54f56d7
|
@ -8,12 +8,15 @@ tags:
|
|||
- taxonomy
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Whilst developing this, and other Drupal websites for clients, I decided that I wanted to categorise content using the taxonomy system. However, I wasn't happy with the way that Drupal displayed the terms lists by default, and I started comparing this to other websites that I look at.
|
||||
|
||||
To start with, I wanted to have something that described what the list was displaying - like in the second example above. I wanted to have the words 'Posted in' displayed before the list of terms. To do this, I had to edit the node template file that exists within my theme folder (sites/all/themes). As I only wanted this change to affect my Blog posts, the file that I needed to change is **node-blog.tpl.php**
|
||||
|
||||
I scrolled down until I found the piece of code that displayed the terms list:
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
```language-php
|
||||
<?php if ($terms): ?>
|
||||
<div class="terms terms-inline">
|
||||
|
@ -58,3 +61,4 @@ This code finds the last item in the list, uses **.prev** to select the one befo
|
|||
content: " and";
|
||||
}
|
||||
```
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,10 +10,13 @@ tags:
|
|||
- imagefield
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Whilst working on my own portfolio/testimonial website, I decided to have a portfolio page displaying the name of each site and a thumbnail image. For this Blog post, I'll be using a site called [Popcorn Strips](http://popcornstrips.com) which I built for a friend earlier this year as an example.
|
||||
|
||||
I created a content type called 'Project' with a CCK ImageField called 'Screenshot'. I created a project called [Popcorn Strips](http://popcornstrips.com), used the [ScreenGrab](https://addons.mozilla.org/addon/1146) add-on for Mozilla Firefox to take a screenshot of the website, and uploaded it to the project node.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
I created a View to display the published projects, and an ImageCache
|
||||
preset to create the thumbnail image by scaling and cropping the image
|
||||
to a size of 200x100 pixels.
|
||||
|
@ -28,3 +31,4 @@ I then added a new 'Javascript crop' action with the following settings:
|
|||
* Height: 100px
|
||||
* xoffset: Left
|
||||
* yoffset: Top
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,10 +9,14 @@ tags:
|
|||
- slideshow
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Whilst updating my About page, I thought about creating a slideshow of several images instead of just the one static image. When I looking on Drupal.org, the only slideshow modules were to create slideshows of images that were attached to different nodes - not multiple images attached to one node. Then, I found the [Fancy Slide](http://drupal.org/project/fancy_slide) module. It's a jQuery Slideshow module with features that include integration with the [CCK](http://drupal.org/project/cck), [ImageCache](http://drupal.org/project/imagecache) and [Nodequeue](http://drupal.org/project/nodequeue) modules.
|
||||
|
||||
I added an CCK Image field to my Page content type, and set the number of values to 3, then uploaded my images to the Page.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Whilst updating my About page, I thought about creating a slideshow of several images instead of just the one static image. When I looking on Drupal.org, the only slideshow modules were to create slideshows of images that were attached to different nodes - not multiple images attached to one node. Then, I found the [Fancy Slide](http://drupal.org/project/fancy_slide) module. It's a jQuery Slideshow module with features that include integration with the [CCK](http://drupal.org/project/cck), [ImageCache](http://drupal.org/project/imagecache) and [Nodequeue](http://drupal.org/project/nodequeue) modules.
|
||||
Once the Images were added, I went to the Fancy Slide settings page and created the slideshow.
|
||||
|
||||
I added the dimensions of my images, the type of animation, specified the node that contained the images, the slideshow field, delay between slides and transition speed. With the slideshow created, it now needed embedding into the page.
|
||||
|
@ -24,3 +28,4 @@ I added the following code into my About page, as described in the Fancy Slide r
|
|||
```
|
||||
|
||||
In my opinion, this adds a nice effect to the About page. I like it because it's easy to set up, and easy to add additional images later on if required.
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,10 +11,13 @@ tags:
|
|||
- imagefield
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
**Thanks to Bob at [Mustardseed Media](http://mustardseedmedia.com) for [tweeting](http://twitter.com/mustardseedinc/status/14713096905) about this module. It's undoubtedly saved me hours of work today alone!**
|
||||
|
||||
I've recently started a personal project converting a website to Drupal. It's currently a static HTML/CSS site which also uses the [Coppermine Photo Gallery](http://coppermine-gallery.net). As part of building the new website, I wanted to move all the photos from the existing site onto the new one. However, with 1260 photos in 17 albums, this could have been a lengthy process!
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
I created a new Drupal-powered Gallery as described in [this screencast](http://lullabot.com/articles/photo-galleries-views-attach) by [Jeff Eaton](http://twitter.com/eaton) - using the CCK and Imagefield modules, and re-created each of my existing Gallery nodes. Using the [Imagefield_Import](http://drupal.org/project/imagefield_import) module, I was then able to quickly import the photos into the new Galleries.
|
||||
|
||||
I downloaded all the photos from the previous Gallery via FTP, and installed and configured the Imagefield_Import module.
|
||||
|
@ -24,3 +27,4 @@ I created an 'Import' folder, selected the target field and mode. In this case,
|
|||
After clicking 'Import', a node is created for each photo, the image is uploaded, and added to the selected Gallery.
|
||||
|
||||
Just another 1248 photos to go...
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,11 +7,15 @@ tags:
|
|||
- imagecache
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Whilst uploading images for my Projects and Testimonials sections, I noticed that the Imagecache-scaled images weren't as high a quality the originals on my Mac. I did some searching online and found out that, by default, Drupal resamples uploaded jpgs to 75% of their original quality.
|
||||
|
||||
To increase the quality of your images, change the setting in the two following places:
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
* admin/settings/imageapi/config
|
||||
* admin/settings/image-toolkit
|
||||
|
||||
The first one is for ImageAPI. Primarily, this means Imagecache presets. The second one is for core's image.inc. This is used for resizing profile pictures in core, and some contrib modules. Once changed, I did have to flush each of the Imagecache presets (admin/build/imagecache) for the changes to take effect.
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,10 +10,13 @@ tags:
|
|||
- oliverdavies.co.uk
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
I recently decided that I wanted to have a block displayed in a sidebar on my site containing icons and links to my social media profiles - [Twitter](http://twitter.com/opdavies), [Facebook](http://facebook.com/opdavies) etc. I tried the [Follow](http://drupal.org/project/follow) module, but it lacked the option to add extra networks such my [Drupal.org](http://drupal.org/user/381388) account, and my [RSS feed](http://oliverdavies.co.uk/rss.xml). I started to create my own version, and then found [this Blog post](http://www.hankpalan.com/blog/drupal-themes/add-your-social-connections-drupal-icons) by Hank Palan.
|
||||
|
||||
I created a 'Social icon' content type with the body field removed, and with fields for a link and image - then downloaded the favicons from the appropriate websites to use.
|
||||
I created a 'Social icon' content type with the body field removed, and with fields for a link and image - then downloaded the favicons from the appropriate websites to use.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
However, instead of using a custom template (node-custom.tpl.php) file, I used the Views module.
|
||||
|
||||
I added fields for the node titles, and the link from the node's content. Both of these are excluded from being displayed on the site. I then re-wrote the output of the Icon field to create the link using the URL, and using the node's title as the image's alternative text and the link's title.
|
||||
|
@ -21,3 +24,4 @@ I added fields for the node titles, and the link from the node's content. Both o
|
|||
I also used the [Nodequeue](http://drupal.org/project/nodequeue) module to create a nodequeue and arrange the icons in the order that I wanted them to be displayed. Once this was added as a relationship within my View, I was able to use node's position in the nodequeue as the sort criteria.
|
||||
|
||||
To complete the process, I used the [CSS Injector](http://drupal.org/project/css_injector) module to add some additional CSS styling to position and space out the icons.
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,10 +7,13 @@ tags:
|
|||
- drupal-modules
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Aside from the obvious candidates such as Views, CCK etc, here are a list of 10 contributed modules that I currently use on each Drupal project.
|
||||
|
||||
So, in no particular order:
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
* **[Admin](http://drupal.org/project/admin):** <br>The admin module provides UI improvements to the standard Drupal admin interface. I've just upgraded to the new [6.x-2.0-beta4](http://drupal.org/node/835870) version, and installed the newly-required [Rubik](http://code.developmentseed.org/rubik)/[Tao](http://code.developmentseed.org/tao) themes. So far, so good!
|
||||
* **[Better Permissions](http://drupal.org/project/better_perms)/[Filter Permissions](http://drupal.org/project/filter_perms): <br>**Basic permissions is a basic module which enhances the Drupal Permissions page to support collapsing and expanding permission rows. Filter permissions provides filters at the top of the Permissions page for easier management when your site has a large amount of roles and/or permissions.
|
||||
* **[Better Formats](http://drupal.org/project/better_formats): <br>**Better formats is a module to add more flexibility to Drupal's core input format system.
|
||||
|
@ -21,3 +24,4 @@ So, in no particular order:
|
|||
* **[Module Filter](http://drupal.org/project/module_filter):**<br>What this module aims to accomplish is the ability to quickly find the module you are looking for without having to rely on the browsers search feature which more times than not shows you the module name in the 'Required by' or 'Depends on' sections of the various modules or even some other location on the page like a menu item.
|
||||
* **[Zenophile](http://drupal.org/project/zenophile):**<br>Quickly create Zen subthemes.
|
||||
* **[Add Another](http://drupal.org/project/addanother):**<br>Add another displays a message after a user creates a node, and/or displays an "Add another" tab on nodes allowing them to make another node of the same type. You can control what roles and node types see this feature.
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,10 +14,13 @@ tags:
|
|||
- imagefield
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
In this tutorial, I'll show you how to create a photo gallery which uses photos imported from [Flickr](http://www.flickr.com).
|
||||
|
||||
The modules that I'll use to create the Gallery are:
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
* [CCK](http://drupal.org/project/cck)
|
||||
* [Feeds](http://drupal.org/project/feeds)
|
||||
* [Feeds Image Grabber](http://drupal.org/project/feeds_imagegrabber)
|
||||
|
@ -44,3 +47,4 @@ With the new Photo nodes created, I then created the View to display them.
|
|||
The View selects the image within the Photo content type, and displays in it a grid using an ImageCache preset. The View is limited to 20 nodes per page, and uses a full pager if this is exceeded. The nodes are sorted by the descending post date, and filtered by whether or not they are published, and only to include Photo nodes.
|
||||
|
||||
As an additional effect, I also included the 'Feeds Item - Item Link' field, which is basically the original link from the RSS feed. By checking the box the exclude the item from the display, it is not shown, but makes the link available to be used elsewhere. By checking the box 'Re-write the output for this field' on the 'Content: Photo' field, I was able to add the replacement token (in this case, [url]) as the path for a link around each image. This meant that when someone clicked a thumbnail of a photo, they were directed to the Flickr website instead of the node within my Drupal site.
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,8 +11,11 @@ tags:
|
|||
- content-types
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
In this post, I will be changing values within my Drupal 6 site's database to quickly change the content type of multiple nodes. I will be using a test development site with the core Blog module installed, and converting Blog posts to a custom content type called 'News article'.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
**Before changing any values within the database, ensure that you have an up-to-date backup which you can restore if you encounter a problem!**
|
||||
|
||||
To begin with, I created the 'News article' content type, and then used the Devel Generate module to generate some Blog nodes.
|
||||
|
@ -24,3 +27,4 @@ Using an SQL 'Update' command, I can change the type value from 'blog' to 'artic
|
|||
Now, when I query the database, the type is shown as 'article'.
|
||||
|
||||
Now, when I go back into the administration section of my site and view the content, the content type now shows at 'News article'.
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,10 +9,13 @@ tags:
|
|||
- virtualhostx
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
This isn't a Drupal related topic per se, but it is a walk-through of one of the applications that I use whilst doing Drupal development work. I assume, like most Mac OS X users, I use [MAMP](http://www.mamp.info/en/index.html) to run Apache, MySQL and PHP locally whilst developing. I also use virtual hosts in Apache to create local .dev domains which are as close as possible to the actual live domains. For example, if I was developing a site called mysite.com, my local development version would be mysite.dev.
|
||||
|
||||
Normally, I would have to edit the hosts file and Apache's httpd.conf file to create a virtual host. The first to set the domain and it's associated IP address, and the other to configure the domain's directory, default index file etc. However, using [VirtualHostX](http://clickontyler.com/virtualhostx), I can quickly create a virtual host without having to edt any files. Enter the virtual domain name, the local path and the port, and apply the settings. VirtualHostX automatically restarts Apache, so the domain is ready to work straight away. You can also enter custom directives from within the GUI.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
There's also an option to share the host over the local network. Next, I intend on configuring a virtual Windows PC within VMware Fusion to view these domains so that I can do cross-browser testing before putting a site live.
|
||||
|
||||
I ensured that my Apache configuration within MAMP was set to port 80, and that VirtualHostX was using Apache from MAMP instead of Apple's built-in Apache.
|
||||
|
@ -22,3 +25,4 @@ I ensured that my Apache configuration within MAMP was set to port 80, and that
|
|||
After some troubleshooting, I found out that Web Sharing on my Mac had become enabled (I don't know why, I've never enabled it), and that this was causing a conflict with Apache. Once I opened my System Preferences and disabled it, everything worked fine!
|
||||
|
||||
This, along with [MAMP](http://www.mamp.info/en/index.html), [Coda](http://www.panic.com/coda), [Sequel Pro](http://www.sequelpro.com), and [Transmit](http://www.panic.com/transmit), has become an essential tool within my development environment.
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,10 +10,13 @@ tags:
|
|||
- database
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
**Update:** This can also be done using the [Views Bulk Operations](http://drupal.org/project/views_bulk_operations) module.
|
||||
|
||||
In preparation for my Blog posts being added to [Drupal Planet](http://drupal.org/planet), I needed to create a new Taxonomy term (or, in this case, tag) called 'Drupal Planet', and assign it to new content to imported into their aggregator. After taking a quick look though my previous posts, I decided that 14 of my previous posts were relevant, and thought that it would be useful to also assign these the 'Drupal Planet' tag.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
I didn't want to manually open each post and add the new tag, so I decided to make the changes myself directly into the database using SQL, and as a follow-up to a previous post - [Quickly Change the Content Type of Multiple Nodes using SQL](/blog/change-content-type-multiple-nodes-using-sql/).
|
||||
|
||||
**Again, before changing any values within the database, ensure that you have an up-to-date backup which you can restore if you encounter a problem!**
|
||||
|
@ -49,3 +52,4 @@ SELECT nid, tid FROM term_node WHERE nid = 216;
|
|||
Once the query had confirmed the correct tid value, I began to write the SQL Insert statement that would be needed to add the new term to the required nodes. The nid and vid values were the same on each node, and the value of my taxonomy term would need to be 84.
|
||||
|
||||
Once this had completed with no errors, I returned to the administration area of my Drupal site to confirm whether or not the nodes had been assigned the new term.
|
||||
{% endblock %}
|
||||
|
|
|
@ -8,10 +8,13 @@ tags:
|
|||
- teleport
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
As a heavily-reliant [Quicksilver](http://en.wikipedia.org/wiki/Quicksilver_%28software%29) user on my MacBook Pro, I was glad when I found the [Teleport](http://drupal.org/project/teleport) module for [Drupal](http://drupal.org) *(due to Elliott Rothman's [tweet](http://twitter.com/elliotttt/status/18044234238))*.
|
||||
|
||||
When you press a configurable hot-key, a jQuery dialog box appears where you can search for nodes by title or path, or directly enter the path that you want to navigate to. This will greatly reduce the number of clicks that I need to perform to get to my desired page - even compared to the [Admin](http://drupal.org/project/admin) and [Administration Menu](http://drupal.org/project/admin_menu) modules.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Although it's not a new module (the first commits were 2 years ago), I hope that they are still planning on achieving the list of future directions listed on their Drupal.org project page:
|
||||
|
||||
* Make interface act more like Quicksilver (i.e. you should only have to press Enter once to launch)
|
||||
|
@ -19,3 +22,4 @@ Although it's not a new module (the first commits were 2 years ago), I hope that
|
|||
* Hook into more non-node content, like taxonomy terms and functions in the API module.
|
||||
|
||||
Personally, this will make navigation around both the front-end and administration area of my Drupal sites so much easier.
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,10 +9,13 @@ tags:
|
|||
- administration
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Sorry for the lack of Blog posts lately, but [my new job](http://horseandcountry.tv) that I started a few weeks ago has certainly been keeping me busy! I've got a few more posts that I'm preparing content for, and I'll hopefully be back into my weekly-post routine before too long!
|
||||
|
||||
Today, I'd like to just give a quick overview of the [Admin:hover](http://drupal.org/project/admin_hover) module. It basically adds an administrative menu that pops up when you hover over a node or block within your Drupal website - the kind of functionality that was present within previous versions of the [Admin module](http://drupal.org/project/admin). It also integrates well with the [Devel](http://drupal.org/project/devel) and [Clone](http://drupal.org/project/node_clone) modules.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
I've found this to be extremely useful whilst working on photo galleries etc. where multiple nodes are displayed in a grid format and I quickly need to publish or unpublish something for testing purposes. No longer do I need to open each node, or go into the administration area to perform the required actions.
|
||||
|
||||
It is also possible to customise which links are available from within the adminstration area. The possible selections that I currently have on this site are as follows:
|
||||
|
@ -39,3 +42,4 @@ It is also possible to customise which links are available from within the admin
|
|||
* Add block
|
||||
|
||||
Although, as I have additional contributed modules installed, some of these may not neccassaily be available out of the box.
|
||||
{% endblock %}
|
||||
|
|
|
@ -13,10 +13,13 @@ tags:
|
|||
- drupal
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Recently, I converted a client's static HTML website, along with their Coppermine Photo Gallery, into a Drupal-powered website.
|
||||
|
||||
Over the next few posts, I'll be replicating the process that I used during the conversion, and how I added some additional features to my Drupal gallery.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
To begin with, I created my photo gallery as described by [Jeff Eaton](http://www.lullabot.com/about/team/jeff-eaton) in [this screencast](http://www.lullabot.com/articles/photo-galleries-views-attach), downloaded all my client's previous photos via FTP, and quickly added them into the new gallery using the [Imagefield Import](http://drupal.org/project/imagefield_import) module (which I mentioned [previously](/blog/quickly-import-multiples-images-using-imagefieldimport-module/)).
|
||||
|
||||
When I compare this to the previous gallery, I can see several differences which I'd like to include. The first of which is the number of photos in each gallery, and the date that the most recent photo was added.
|
||||
|
@ -121,3 +124,4 @@ if ($selected_gallery_total != 0) {
|
|||
The values that I've entered are from [this page](http://php.net/manual/en/function.date.php) on PHP.net, and can be changed according on how you want the date to be displayed.
|
||||
|
||||
As I've added all of these photos today, then the correct dates are being displayed. However, on the client's original website, the majority of these photos were pubished several months or years ago, and I'd like the new website to still reflect the original created dates. As opposed to modifying each individual photograph, I'll be doing this in bulk in my next post.
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,10 +9,13 @@ tags:
|
|||
- sequel-pro
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
At the end of my last post, I'd finished creating the first part of the new photo gallery, but I wanted to change the dates of the published photos to reflect the ones on the client's original website.
|
||||
|
||||
Firstly, I'll refer to the previous list of published galleries that I created before, and create something different that also displays the created and modified dates. Picking the node ID of the required gallery, I used the following SQL query to display a list of photos.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
```language-sql
|
||||
SELECT n.title, n.nid, n.created, n.changed, p.field_gallery_nid
|
||||
FROM node n, content_type_photo pWHERE n.type = 'photo'
|
||||
|
@ -39,3 +42,4 @@ Now when I query the database, both the created and modified databases have bee
|
|||
Once the changes have been applied, it's a case of repeating the above process for each of the required galleries.
|
||||
|
||||
In the next post, I'll explain how to add a count of published galleries and photos on the main photo gallery page, as well as how to install and configure the [Shadowbox](http://drupal.org/project/shadowbox) module.
|
||||
{% endblock %}
|
||||
|
|
|
@ -9,10 +9,13 @@ tags:
|
|||
- image-caption
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Up until as recent as last week, whenever I added an image into one of my Blog posts, I was manually adding the caption below each image and styling it accordingly. That was until I installed the [Image Caption](http://drupal.org/project/image_caption) module.
|
||||
|
||||
The Image Caption module uses jQuery to dynamically add captions to images. Here is a walkthrough of the process that I followed to install and configure the module. As always, I used Drush to download and enable the module, then visited the Image Caption Settings page (admin/settings/image_caption). Here, I select which node types should be included in image captioning. In my case, I only wanted this to apply to Blog posts.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
As I use the [FileField](http://drupal.org/project/filefield), [ImageField](http://drupal.org/project/imagefield) and [Insert](http://drupal.org/project/insert) modules to add images to my posts, as opposed to via a WYSIWYG editor, I'm able to add the CSS class of 'caption' to my images.
|
||||
|
||||
Now, all images inserted this way will have the CSS class of 'caption'.
|
||||
|
@ -22,3 +25,4 @@ As the Image Caption module uses the image's title tag to create the displayed c
|
|||
This results in a span called `image-caption-container` around the inserted image, and a caption below it called `image-caption` containing the text.
|
||||
|
||||
All that's left is to style these classes within your CSS stylesheet.
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,10 +5,13 @@ tags:
|
|||
- drupal
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
The next part of the new gallery that I want to implement is to group the galleries by their respective categories. The first step is to edit my original photo_gallery view and add an additional display.
|
||||
|
||||
I've called it 'Taxonomy', and it's similar to the original 'All Galleries' view. The differences are that I've added the taxonomy term as an argument, removed the header, and updated the path to be `gallery/%`. The other thing that I need to do is overwrite the output of the original 'All Galleries' View by creating a file called `views-view--photo-gallery--page-1.tpl.php` and placing it within my theme directory.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Within that file, I can remove the standard content output. This still outputs the heading information from the original View. I can now use the function called 'views_embed_view' to embed my taxonomy display onto the display. The views_embed_view function is as follows:
|
||||
|
||||
```language-php
|
||||
|
@ -32,3 +35,4 @@ while ($term = db_fetch_array($terms)) {
|
|||
}
|
||||
?>
|
||||
```
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,8 +5,11 @@ tags:
|
|||
- drupal
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Today, I realised that I hadn't published the code that I used to create the total figures of galleries and photos at the top of the gallery (I said at the end of [Part 2](/blog/create-better-photo-gallery-drupal-part-2/ "Create a Better Photo Gallery in Drupal - Part 2") that I'd include it in [Part 3](/blog/create-better-photo-gallery-drupal-part-3/ "Create a Better Photo Gallery in Drupal - Part 3"), but I forgot). So, here it is:
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
```language-php
|
||||
<?php
|
||||
|
||||
|
@ -54,3 +57,4 @@ print '.';
|
|||
```
|
||||
|
||||
It was applied to the view as a header which had the input format set to PHP code.
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,8 +10,11 @@ tags:
|
|||
- textmate
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
As in [the original post](/blog/add-taxonomy-term-multiple-nodes-using-sql/ "Quickly adding a taxonomy term to multiple nodes using SQL"), I'd generated a list of node ID values, and needed to add structure the SQL update statment formatted in a certain way. However, I changed my inital query slightly to out put the same nid value twice.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
```language-sql
|
||||
SELECT nid, nid FROM node WHERE TYPE = 'blog' ORDER BY nid ASC;
|
||||
```
|
||||
|
@ -36,3 +39,4 @@ All 31 lines have been changed.
|
|||
Next, I can use `\n` to target the lines between the rows. I'll replace it with the next comma, the number 63 (the tid value), the closing bracket, another comma, re-add the line and add the opening bracket.
|
||||
|
||||
The only two lines that aren't changed are the first and last, as they don't have any line breaks following them. I can complete these lines manually. Now all I need to do is add the beginning of the SQL update statement, then copy and paste it into Sequel Pro.
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,8 +6,11 @@ tags:
|
|||
- php
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Replace the $page_id value with your Page ID number (unless you want to show the number of fans for this site).You can find your Page ID by logging into your Facebook account, going to 'Adverts and Pages', clicking 'Edit page', and looking at the URL.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
For example, mine is <https://www.facebook.com/pages/edit/?id=143394365692197&sk=basic>.
|
||||
|
||||
I've also wrapped the output in a number_format() function so that it properly formatted with commas etc - like where I've used it within the [Gold Event listing](http://www.horseandcountry.tv/events/paid) on the Horse & Country TV website.
|
||||
|
@ -20,3 +23,4 @@ print number_format($fans);
|
|||
```
|
||||
|
||||
This code was originally found at <http://wp-snippets.com/display-number-facebook-fans>.
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,10 +11,13 @@ tags:
|
|||
- multigroup
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
One of my favourite things lately in Drupal 6 has been CCK 3, and more specifically, the Content Multigroups sub-module. Basically this allows you to create a fieldset of various CCK fields, and then repeat that multiple times. For example, I use it on this site whist creating invoices for clients. I have a fieldset called 'Line Item', containing 'Description', 'Quantity' and 'Price' fields. With a standard fieldset, I could only have one instance of each field - however, using a multigroup, I can create multiple groups of line items which I then use within the invoice.
|
||||
|
||||
But at the time of writing this, there is no CCK 3 version for Drupal 7. So, I created the same thing using [Field Collection](http://drupal.org/project/field_collection) and [Entity](http://drupal.org/project/entity) modules.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
With the modules uploaded and enabled, go to admin/structure/field-collections and create a field collection.
|
||||
|
||||
With the module enabled, you can go to your content type and add a Field Collection field. By default, the only available Widget type is 'Hidden'.
|
||||
|
@ -28,3 +31,4 @@ Whilst this works perfectly, the field collection is not editable from the node
|
|||
After some searching I found [a link to a patch](http://drupal.org/node/977890#comment-4184524) which when applied adds a 'subform' widget type to the field collection field and allows for it to be embedded into, and editable from within the node form. Going back to the content type fields page, and clicking on 'Hidden' (the name of the current widget), I can change it to subform and save my changes.
|
||||
|
||||
With this change applied, when I go back to add or edit a node within this content type, my field collection will be easily editable directly within the form.
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,10 +7,13 @@ tags:
|
|||
- version-control
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Recently, I needed to set up a Subversion (SVN) server on a Ubuntu Linux server. This post is going to outline the steps taken, and the commands used, to install and configure the service.
|
||||
|
||||
Note: As I was using Ubuntu, I was using the 'apt-get' command to download and install the software packages. If you're using a different distribution of Linux, then this command may be different. I'm also assuming that Apache is already installed.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Firstly, I'm going to ensure that all of my installed packages are up to date, and install any available updates.
|
||||
|
||||
```language-bash
|
||||
|
@ -146,3 +149,4 @@ $ svn add *
|
|||
```
|
||||
|
||||
With all the required files added, they can be committed using `svn commit -m 'commit message'` command, and the server can be updated using the svn up command.
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,8 +6,11 @@ tags:
|
|||
- ssh
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
If you're accessing Linux servers or automating tasks between servers, rather than having to enter your user password every time, you can also use SSH public key authentication. This is a simple process that involves creating a local key and storing it within the *authorized_keys* file on the remote server.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
1. Check if you already have a SSH key.
|
||||
`$ ssh-add -L`
|
||||
2. If you don't have one, create one.
|
||||
|
@ -26,3 +29,4 @@ If successful, you should now see a message like:
|
|||
> to make sure we haven't added extra keys that you weren't expecting.
|
||||
|
||||
Now the next time that you SSH onto the server, it should log you in without prompting you for your password.
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,10 +10,13 @@ tags:
|
|||
- drupal
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
In this tutorial I'll be showing how to create an [Omega](http://drupal.org/project/omega) subtheme using the [Omega Tools](http://drupal.org/project/omega_tools) module, and have it working with the [LESS CSS preprocessor](http://lesscss.org).
|
||||
|
||||
The first thing that I need to do is download the Omega theme and the Omega Tools and [LESS](http://drupal.org/project/less "LESS module on drupal.org") modules, and then to enable both modules. I'm doing this using Drush, but you can of course do this via the admin interface at admin/modules.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
```language-bash
|
||||
$ drush dl less omega omega_tools;
|
||||
$ drush en -y less omega_tools
|
||||
|
@ -40,3 +43,4 @@ $ drush cc all
|
|||
I tested my changes by making some quick additions to my global.less file and reloading the page.
|
||||
|
||||
If your changes aren't applied, then confirm that your global.less file is enabled within your theme's configuration. I did this by going to admin/appearance/settings/oliverdavies, clicking on the Toggle styles tab within *Layout configuration* and finding global.less at the bottom of *Enable optional stylesheets*.
|
||||
{% endblock %}
|
||||
|
|
|
@ -12,10 +12,13 @@ meta:
|
|||
type: article
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
This week, my first code patch was [committed to Drupal core](https://www.drupal.org/node/2394517#comment-9773143). The patch adds the `user_has_role()` function to the user module, to simplify the way to check whether a user in Drupal has been assigned a specific role. This is something that I normally write a custom function for each project, but it's now available in Drupal core as of [7.36](https://www.drupal.org/drupal-7.36-release-notes).
|
||||
|
||||
But what if someone is using a core version less than 7.36 and tries using the function? The site would return an error because that function wouldn't exist.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
If you're building a new Drupal site, then I'd assume that you're using a latest version of core, or you have the opportunity to update it when needed. But what if you're writing a contrib module? How can you be sure that the correct minimum version of core?
|
||||
|
||||
## Setting Dependencies
|
||||
|
@ -69,3 +72,4 @@ Because we need to check for Drupal's core version, we're using the system modul
|
|||
## External Links
|
||||
|
||||
* [Writing module .info files (Drupal 7.x)](https://www.drupal.org/node/542202#dependencies)
|
||||
{% endblock %}
|
||||
|
|
|
@ -10,13 +10,15 @@ tags:
|
|||
- sculpin
|
||||
use: [posts]
|
||||
---
|
||||
{% block content %}
|
||||
{% block excerpt %}
|
||||
## Sculpin
|
||||
|
||||
People may or may not know, but this site runs on [Sculpin](https://sculpin.io/), a PHP based static site generator (this may be the first time that I've mentioned it on this site). The source code is hosted on [GitHub](https://github.com/opdavies/oliverdavies.uk), and I've listed the site on the [Community page](https://sculpin.io/community/) on the Sculpin website.
|
||||
|
||||
To get it there, I forked the [main sculpin.io repository](https://github.com/sculpin/sculpin.io) so that I had [my own copy](https://github.com/opdavies/sculpin.io), created a branch, made my additions and submitted a pull request. Easy enough!
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
## New Domain
|
||||
|
||||
In the last week or so, I've changed this site URL from .co.uk to just .uk, and also updated the GitHub repo URL to match, so I wanted to update the Community page to use the correct URL.
|
||||
|
|
|
@ -7,8 +7,11 @@ tags:
|
|||
slug: automating-sculpin-jenkins
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
As part of re-building this site with [Sculpin](http://sculpin.io), I wanted to automate the deployments, as in I wouldn't need to run a script like [publish.sh](https://raw.githubusercontent.com/sculpin/sculpin-blog-skeleton/master/publish.sh) locally and have that deploy my code onto my server. Not only did that mean that my local workflow was simpler (update, commit and push, rather than update, commit, push and deploy), but if I wanted to make a quick edit or hotfix, I could log into GitHub or Bitbucket (wherever I decided to host the source code) from any computer or my phone, make the change and have it deployed for me.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
I'd started using [Jenkins CI](http://jenkins-ci.org) during my time at the Drupal Association, and had since built my own Jenkins server to handle deployments of Drupal websites, so that was the logical choice to use.
|
||||
|
||||
## Installing Jenkins and Sculpin
|
||||
|
@ -130,3 +133,4 @@ fi
|
|||
```
|
||||
|
||||
I've been working on a `redirects.php` script that generates redirects from a .csv file, after seeing similar things in the [Pantheon Documentation](https://github.com/pantheon-systems/documentation) and [That Podcast](https://github.com/thatpodcast/thatpodcast.io) repositories. This checks if that file exists, and if so, runs it and generates the source file containing each redirect.
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,10 +5,13 @@ tags:
|
|||
- gmail
|
||||
use: [posts]
|
||||
---
|
||||
{% block excerpt %}
|
||||
Earlier this week I wrote a small PHP library called [GmailFilterBuilder][0] that allows you to write Gmail filters in PHP and export them to XML.
|
||||
|
||||
I was already aware of a Ruby library called [gmail-britta][1] that does the same thing, but a) I’m not that familiar with Ruby so the syntax wasn’t that natural to me - it’s been a while since I wrote any Puppet manifests, and b) it seemed like a interesting little project to work on one evening.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
The library contains two classes - `GmailFilter` which is used to create each filter, and `GmailFilterBuilder` that parses the filters and generates the XML using a [Twig][2] template.
|
||||
|
||||
## Usage
|
||||
|
@ -72,6 +75,7 @@ For a working example, see my personal [gmail-filters][3] repository on GitHub.
|
|||
* [The GmailFilterBuilder library on Packagist][4]
|
||||
* [My Gmail filters on GitHub][3]
|
||||
* [My Twig Extensions on Packagist][5]
|
||||
{% endblock %}
|
||||
|
||||
[0]: https://github.com/opdavies/gmail-filter-builder
|
||||
[1]: https://github.com/antifuchs/gmail-britta
|
||||
|
|
|
@ -12,8 +12,6 @@ draft: true
|
|||
Recently, I reviewed [a patch][1] in the [Override Node Options][2] module issue queue. For those not familiar with it, the module adds extra permissions for node options like "authored by" and "published on" which are normally only available to users with the `administer nodes` permission. What the patch does is to optionally add another set of permissions that enable options for all content types - e.g. "override published option for all node types", in addition to or instead of the content type specific ones.
|
||||
|
||||
It was quite an old issue and the latest patch needed to be re-rolled due to merge conflicts, but the existing tests still passed. Though as no new tests were added for the new functionality, these needed to be added before I committed it.
|
||||
|
||||
This post documents the steps that I took to update the tests to add the proposed functionality.
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -19,13 +19,13 @@ slug: drupalcamp-bristol-early-bird-tickets-sessions-sponsors
|
|||
<p class="text-center" markdown="1">![DrupalCamp Bristol 2017 logo](/assets/images/blog/drupalcamp-bristol-17-logo.jpg)</p>
|
||||
|
||||
In less than two months time, [DrupalCamp Bristol][0] will be back for our third year! (July seems to come around quicker each year). This is this year’s schedule and venues:
|
||||
|
||||
+ 30th June - CXO (Business) day - [Watershed][1]
|
||||
+ 1st July - Developer conference - [University of Bristol, School of Chemistry][2]
|
||||
+ 2nd July - Contribution sprints - Venue TBC
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
+ 30th June - CXO (Business) day - [Watershed][1]
|
||||
+ 1st July - Developer conference - [University of Bristol, School of Chemistry][2]
|
||||
+ 2nd July - Contribution sprints - Venue TBC
|
||||
|
||||
Today we announced [Emma Karayiannis][3] as our Saturday keynote speaker, and we’ll be announcing some of the other speakers later this week.
|
||||
|
||||
Not submitted your session yet? The [session submissions][12] are open until May 31st. We’re looking for talks not only on Drupal, but other related topics such as PHP, Symfony, server administration/DevOps, project management, case studies, being human etc. If you want to submit but want to ask something beforehand, please [send us an email][4] or ping us on [Twitter][5].
|
||||
|
|
|
@ -11,11 +11,12 @@ slug: turning-drupal-module-into-feature
|
|||
Yesterday I was fixing a bug in an inherited Drupal 7 custom module, and I decided that I was going to add some tests to ensure that the bug was fixed and doesn’t get accidentially re-introduced in the future. The test though required me to have a particular content type and fields which are specific to this site, so weren’t present within the standard installation profile used to run tests.
|
||||
|
||||
I decided to convert the custom module into a [Feature][0] so that the content type and it’s fields could be added to it, and therefore present on the testing site once the module is installed.
|
||||
|
||||
To do this, I needed to expose the module to the Features API.
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
To do this, I needed to expose the module to the Features API.
|
||||
|
||||
All that’s needed is to add this line to the `mymodule.info` file:
|
||||
|
||||
```language-ini
|
||||
|
|
|
@ -19,13 +19,17 @@ use: [posts]
|
|||
|
||||
{% include 'post/intro-image' with { page: post } %}
|
||||
|
||||
{% if post.blocks.excerpt %}
|
||||
{{ post.blocks.excerpt|raw }}
|
||||
{% else %}
|
||||
<p>{{ post.blocks.content|raw|striptags|split(' ')|slice(0,50)|join(' ')|replace({ 'h2': 'h3' }) }} …</p>
|
||||
{% endif %}
|
||||
<div class="mb-4">
|
||||
{% if post.blocks.excerpt %}
|
||||
{{ post.blocks.excerpt|markdown }}
|
||||
{% else %}
|
||||
{{ post.blocks.content|markdown }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<p><a href="{{ post.url }}">Read more →</a></p>
|
||||
<p>
|
||||
<a href="{{ post.url }}">Read more →</a>
|
||||
</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue