Profile

Cover photo
Dave Foy
Works at Woof
Attended St John Southworth, Preston
Lived in Preston
72 followers|12,263 views
AboutPostsPhotosVideos

Stream

Dave Foy

How Do I?  - 
 
Having an issue with implementing search on the front end of a site.

I'm using the exact code from the docs:

http://buildwithcraft.com/docs/templating/search-form

If I search for a term that I know isn't contained in the site, my template outputs '0 results', not 'Your search for "iguanas doing the conga" didn’t return any results.' which is what I'd expect.

Seems like Craft thinks there are 'entries' even though there aren't.

Thanks for the help.
1
Dave Foy's profile photoBrandon Kelly's profile photo
4 comments
 
Works a treat. Thanks +Brandon Kelly!
Add a comment...
 
I have a channel section with multiple entries within it. Entries are viewed in /section/{slug}

There isn't a listing page at http://example.com/section. What I'd like is for the 1st/top entry in this section to display at that URL. Basically the first page in this section of the site. At the moment, I can only view that entry at http://example.com/section/name-of-post. Obviously that's expected,. But how might I be able to view it at http://example.com/section?

If I can't do that, then there'll be no page whatsoever at http://example.com/section (the top level), which from an information architecture point of view is not too desirable.

Hope I've explained myself clearly enough.

Thanks for any help.
1
Stuart Whitehead's profile photoDave Foy's profile photo
4 comments
 
Happy to report this works fantastically well. Thanks (again)!
Add a comment...

Dave Foy

How Do I?  - 
 
I'm trying to create a linked list of all tags. I've managed to do it but can't work out how to set the sort order. I'm trying to set it by 'title desc'.

Here's what I've got (simplified):

{% for years in craft.tags.find({order: 'title desc'}) %}
   <li>{{ years.name }}</li>
{% endfor %}

I get a CDbException error page. If I remove the {order: 'title desc'} then the page loads fine, albeit with my tags in an undesired order.

Thanks.
1
Stuart Whitehead's profile photoAlexander Sundli-Härdig's profile photoDave Foy's profile photoBrandon Kelly's profile photo
4 comments
 
Thanks +Stuart Whitehead (and +Brandon Kelly) - checking the docs in the proper place would really have been helpful! Thanks v much indeed.
Add a comment...

Dave Foy

How Do I?  - 
 
When using the Craft contact form plugin, how do I control which fields are required?

I see here.... https://github.com/pixelandtonic/ContactForm/

"The only required fields are “fromEmail” and “message”. Everything else is optional."

Is that hard-coded?
2
Brandon Kelly's profile photoDave Foy's profile photo
6 comments
 
OK, thanks. I'll see what I can do...
Add a comment...

Dave Foy

How Do I?  - 
 
Sanity check please.

I'm about to make a new Craft site live and am writing some 301 redirects from old URLs to new. 

Example:

RewriteEngine On
Redirect 301 /old.html http://www.newsiteexample.com/new-page-1
Redirect 301 /older.html http://www.newsiteexample.com/new-page-2

Problem is, the redirected pages have this appended to them:

?p=old.html

Like:

http://www.newsiteexample.com/new-page-1?p=old.html

Seems that if I remove ?p=$1 in Craft's .htaccess rewrite rules that the problem goes away and the rewrites work correctly and I can continue to view all pages on the site without index.php in the URL.

Can you tell me if there are any issues in future with removing that from your .htaccess rule that I'm not currently seeing?

Thanks.
1
Dave Foy's profile photoBrandon Kelly's profile photo
6 comments
 
Thanks Brandon. Funny, your suggested redirect rule works fine with one Craft site but still gives a 500 internal server error on another. Exact same server, exact same .htaccess file contents.

As I say, I'm asking for support from my host. Thanks for your help with this, appreciate a little outside your support remit. 
Add a comment...
Have him in circles
72 people
Gary Brown's profile photo
Stuart Whitehead's profile photo
Mark Chubbock's profile photo
Ellie Conway's profile photo

Dave Foy

How Do I?  - 
 
I've created a few photo galleries in Craft, using Matrix. I have a block containing 3 fields: asset upload, alt text and caption. Client can then drag the order of blocks around, optionally disable them, etc. So far, so good.

However, I've discovered today that you can CMD-click select a whole load of images from the upload window in one go, which the client loves. Obviously this isn't possible with my current method of having 1 Matrix block per image, as each image has to be added 1 at a time, so....

In theory, could I create a gallery instead by having a single asset upload field, allowing for infinite number of uploads? I could attach custom fields to the images for captions, etc....

Sorry I know this is quite a basic question. Just wondering if I'm missing something obvious that would blow this plan out of the water?

Thanks.
1
Stuart Whitehead's profile photoJosh Angell's profile photoDave Foy's profile photo
4 comments
 
Happy to help!
Add a comment...

Dave Foy

How Do I?  - 
 
I'm using the following code to display a list of tags, linked to their own URL page.

{% for years in craft.tags.find({order: 'name desc'}) %}
<a href="{{ siteUrl }}results/{{ years.name | url_encode }}">{{ years.name }}</a>
{% endfor %}

So far so good. However, I have a set of entries, all with 'entry is enabled' UN-checked, all with the same tag, and this tag is being displayed in the tag list too, even though none of the entries with that tag are live yet. 

How do I stop tags being returned in this list that are from disabled entries?

Thanks.
1
Stuart Whitehead's profile photoDave Foy's profile photoMike Pepper's profile photo
5 comments
 
Always a pleasure.

Cool, nice tip +Mike Pepper :)
Add a comment...

Dave Foy

How Do I?  - 
 
Having a brain failure here....

I have an events section and a news section. I've created an 'entries' related field in the news section. When client adds a news story they can choose which 'event' entry the news story is about.

On the detail template for each event, I want to display any news stories that have been related to it. 

I'm currently using the standard...

{% for entry in craft.entries.find({section: 'news'}) %}

...to display all news stories on the event detail page. How would I adapt this to show only news stories related to the event being viewed?

Thanks.
1
Joshua Baker's profile photoDave Foy's profile photo
2 comments
 
Thanks Josh.
Add a comment...

Dave Foy

How Do I?  - 
 
I'm struggling getting my head around what is probably pretty basic stuff with a Structure section. I'm definitely making this harder than it needs to be!

The main nested nav is no problem. It's conditionally showing content on the pages (listing-style links to sub-pages) that's causing me a headache.

I have 2 entry types for this Structure section: 'buildings' and 'products'. Top-level will always be a 'buildings' entry type. After that, 2nd level could be either another 'buildings' entry or could be 'products'. 3rd level prob only 'products'.

If a page in this section has children, I need to display a listing-style title/summary/link to them on the page itself, but only to the next level of children.  It'll be in 1 particular visual style if a listing of 'building' entry type, and in another style (and also displayed on another part of the page) if a 'products' entry type.

An example possible structure:

1. Building (just page content, no listing cos no sub-pages)
2. Building (page content and listing to sub-pages)
      > Building (page content and don't show listing to this level anymore)
      > Building
      > Building
3. Building
      > Building (page content and product sub-level listing)
            >> Product (page content for this entry type, don't show product listings anymore for this level)
            >> Product
      > Building
4. Building
      > Product
      > Product

I'm getting close but I think my main problem is that my {% nav %} code I'm using to show these listings is showing the same listing again even when I've clicked through to a sub-building or sub-product. 

Struggling to explain! Can anyone please give me a pointer in the right direction? As I say, I'm certainly making this much more complicated than it probably is.

Thanks for your help.
1
Stuart Whitehead's profile photoDave Foy's profile photo
4 comments
 
No problem +Dave Foy, enjoy :)
Add a comment...

Dave Foy

How Do I?  - 
 
Hi - shouldn't this image code only be conditionally output if an image has been uploaded to mainImage?

If there's no main image I'm getting a template error about null data.

{% set blocks = entry.mainImage %}
                {% if blocks | length %}
{% for block in blocks %}
{% set image = block.uploadMainImage.first() %}
                   <img id="mainimg" src="{{ image.getUrl('header') }}" alt='{{ block.uploadMainImageAlternativeText }}' />
                   {% endfor %}
{% endif %}

What am I missing (apart from brain cells)? Thanks!
1
Lewis Jenkins's profile photoKeith Mancuso's profile photoDave Foy's profile photoBrandon Kelly's profile photo
5 comments
 
Thanks both. Actually {% if image %}...{% endif %} works just fine. Obvious really! :)
Add a comment...
People
Have him in circles
72 people
Gary Brown's profile photo
Stuart Whitehead's profile photo
Mark Chubbock's profile photo
Ellie Conway's profile photo
Work
Occupation
Online Marketing
Employment
  • Woof
    Partner, 2010 - present
  • Definition
    Director, 2004 - 2011
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Previously
Preston - Hull
Links
YouTube
Contributor to
Story
Tagline
Keep the cups of tea coming.
Introduction

Hi I'm Dave. I'm one half of Woof, a small online marketing consultancy based in Hull, UK. 

I cook a world-renowned chicken curry, threaten to do a lot of sporting activities (of which very little actually come off), and am a bit on the musical side. I also despise dogs with a passion (but stop short of kicking them).

Education
  • St John Southworth, Preston
    1983 - 1988
  • Newman College, Preston
    1988 - 1990
  • University of Hull
    BA Hons in something or other, 1990 - 1993
  • University of Hull
    PGCE, 1997 - 1998
Basic Information
Gender
Male