Skip to main content

Questions tagged [relations]

Questions around Craft's relational field types.

Filter by
Sorted by
Tagged with
1 vote
1 answer
178 views

Nearest entry using related entry Smart Map field

I’m trying to build a query to get the geographically closest entries, based on an Smart Map field value within a related entry. The following template tags were my first guess, but returned an empty ...
Joshua Baker's user avatar
1 vote
3 answers
356 views

Perform inclusive relatedTo query with multiple categories in Craft 2.5+ [closed]

I'm trying to to display entries related to "all" the given categories instead of "any" using the updated relatedTo method provided in Craft 2.5. In a related question, @BrandonKelly explains how to ...
jthomas's user avatar
  • 373
3 votes
0 answers
510 views

How can I use the ElementAPI to get related entries based on two parameters?

I can successfully get entries related the "normal" way, but my list of possible results are getting quite large. Currently I am returning html mixed in with the data. It's obvious I need to get just ...
Damon's user avatar
  • 4,706
2 votes
1 answer
1k views

How can I get an entry based on category and slug (via url segments)?

I am using (and have used) this S.O post to create a product filter/search using multiple categories. Everything is working perfectly. I am attempting to use the same type of logic to grab ultimately ...
Damon's user avatar
  • 4,706
4 votes
1 answer
237 views

Filter entries on a page based on related entry

This is blowing my mind! I have a Section with handle practiceAreas. I have a Section with handle barristers with approximately 100 entries. barristers has an Entries fieldType called specialisms ...
Martin's user avatar
  • 1,203
2 votes
1 answer
1k views

SuperTable and related entries

I'm trying to pull through content based on items within a SuperTable entries field. After searching around I currently have this: {% set individuals = craft.entries({section: 'barristers', ...
Martin's user avatar
  • 1,203
2 votes
1 answer
206 views

Is it possible to limit the level at which entries can be selected from within an entries field?

I have an entires field which is using a structure as a source. The structure has 3 levels and I would like to be able to limit it so the user can only select entries at the second level. I've had a ...
Andy's user avatar
  • 335
0 votes
1 answer
57 views

Omitting current entry from list of entries generated from a relationship

On my template I am showing detail of an entry. Beneath this I am showing a list of other entries that share the same kind of category relationship as the entry being viewed. This list currently ...
foamcow's user avatar
  • 2,029
2 votes
1 answer
199 views

How do I display entries, grouped by distinct categories where the entries share a relationship to both the category and an entry in another channel

I have 2 channels:survivors, survivorContent and a Category:themes. Relationships are as follows: survivorContent has -> related themes (max 3) AND survivorContent has -> related survivors (max 1) ...
miromo's user avatar
  • 21
4 votes
1 answer
2k views

Checking if current entry exists in an entry custom field in a different entry

I thought this would be simple but I am having no luck with it. I have a channel called "Posts" and for each Post there an "entry" custom field which lists all "Projects" (a structure). The user can ...
Anna's user avatar
  • 127
2 votes
1 answer
812 views

Searching for entries across multiple fields including a relationship

I'm trying to fetch a set of entries based on search parameters. The search is an "and" search, meaning that if criteria exist then they should all match for there to be a result returned. I have ...
foamcow's user avatar
  • 2,029
1 vote
1 answer
165 views

Problem getting relationship between entries to work

I'm having trouble getting what should be a simple relationship between 2 channels to work as expected. This is how things are set up. Channel: Apprenticeships - essentially categories, types of ...
foamcow's user avatar
  • 2,029
4 votes
1 answer
322 views

Limit search results for users by tag (and limit to 5 tags)

I've read as many forum posts and documentation but am a little stumped over a specific use-case. Currently the search page grabs the url segment, loops through a verified user group, and uses the ....
Rob's user avatar
  • 865
1 vote
2 answers
2k views

using craft.request.getParam to filter by relations

I'm requesting entries through a search field like so: {% set params = { section: 'tours', startloc: craft.request.getParam('zoekplaats') } %} {% for entry in craft.entries(params) %} .....
Niels's user avatar
  • 75
3 votes
1 answer
774 views

Search for related entries via AJAX given multiple parameters

I am attempting to create a relationship between products. I have a section named "product" which is a Structure. Each "product" entry has a category field called "species" and a category field called ...
Damon's user avatar
  • 4,706
2 votes
1 answer
829 views

Using relatedTo, and/or and :empty/:notempty in queries

I got users that has 3 Entries fields in their profile: breadForMonday, breadForWednesday and breadForFriday. I want to differentiate between users with 1, 2 or 3 selected entries. How would I use ...
Fred Carlsen's user avatar
  • 2,997
2 votes
1 answer
270 views

List related siblings

I've been reading a lot of documentation (getSiblings, getDescendants etc) but can't get this to work: I have a structure, named 'areas'. When showing an entry that is a child of an area in 'areas', ...
osh's user avatar
  • 91
3 votes
1 answer
160 views

Showing entries within a category

I have a list of people with skills defined by a category group. I have a category field within the 'people' Section so when a new person (entry) is created, the category field allows the admin to ...
Martin's user avatar
  • 1,203
2 votes
1 answer
325 views

Category filter returning all entries

I've been trying to build a category filter. I managed to make my buttons respond with categories but the returned entries on the page stay the same. So when I click one of the links "/?category=koop" ...
sanderfish's user avatar
3 votes
1 answer
604 views

Get all entries attributed with category

Maybe I'm going mad here, but I can't figure out how to get all entries which are in a certain category. Following the syntax laid out here: http://buildwithcraft.com/help/entries-related-to-category ...
Sebastian Thomas's user avatar
4 votes
2 answers
380 views

Is it possible to order related entries by relevance of tags?

I have a set of entries which each have 0 or more tags (no limit). For each entry, I am aiming to display 3 'related entries', related by the tags field. e.g. If entry 1 is tagged with 'apples', '...
Mike Vaux's user avatar
  • 480
2 votes
2 answers
409 views

Only fetch categories that are related to a minimum of entries

Is there a way to only fetch categories that have been assigned to a minimum of entries, i.e. 4? Currently I fetch categories like this: {% set productIds = craft.entries.section('products').ids() %}...
Katrin's user avatar
  • 674
2 votes
2 answers
65 views

Associating related entries to a new entry when using the API

This may just be a 5PM Friday issue, but I'm scratching my head over here. I'm trying to associate a string of related entry id's represented by a variable with a new entry via the API. When I pass ...
kestonh's user avatar
  • 63
8 votes
1 answer
990 views

How to get entries related to current category only (not children)

I need to get entries which are only in current category, not child categories. So if I have a category structured like this: Food ----Fruit -------Apples -------Bananas I've got a categories ...
Mark Gifford's user avatar
3 votes
2 answers
189 views

Help developing point system for sports league (w/o plugins)

I'm in the middle of a very long project developing a league site for the National Collegiate Wrestling Association in my spare time (once finished, could be a great showcase for Craft). Currently, I'...
Chase Giunta's user avatar
2 votes
1 answer
155 views

Get different kind of entries relatedTo one asset (many to one)?

I got an asset field called docs which is contained in 2 different entries. Those entries are in different sections and they contain the docs field directly or through a matrix field called ...
Miguel Bocquier's user avatar
1 vote
1 answer
1k views

How to integrate with Hubspot

For a big client we are required to set up their blog on their Hubspot account. However we are developing everything else in Craft. What is the easiest way to make the connection so the client can ...
Matteo's user avatar
  • 151
2 votes
2 answers
2k views

Get current entry category

I haven't used categories before so maybe I'm looking at this the wrong way. I currently have a category group named products with the following structure: Featured Fruit ----Apple ----Banana Veg ---...
Mark Gifford's user avatar
2 votes
1 answer
851 views

Find entries related to user and display field name

If I’m finding all the entries that are related to a user, how could I get the field handle that the found user is referenced from? {% set events = craft.entries.section('events').relatedTo(user) %} {...
Chase Giunta's user avatar
4 votes
2 answers
709 views

Filter locations by country in Smart Map

I'm using Smart Map to find locations ordered by distance. But I can only set 3 parameters: target, range and units. However, when my range goes beyond the country borders I obviously get results in ...
Tom De Smet's user avatar
  • 1,456
2 votes
1 answer
123 views

Mysql error when defining related tables

I'm trying to create some relational tables from 2 records but I keep getting the mysql error: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1005 Can't create table ...
Mark Gifford's user avatar
1 vote
1 answer
617 views

Relationship through Matrix field

I'm having a little trouble wrapping my head around Relations through a Matrix field. I have a Structure called exhibitors. I have a Matrix field on a Page called rooms, This has one block type room ...
Steve Holland's user avatar
1 vote
0 answers
291 views

Is there any way to create reciprocal related entries?

I'm working on a sign language dictionary project. Each individual sign (or word) is an entry. I want to be able to have an area that shows words that are similar to the word that is being currently ...
Justin K's user avatar
  • 309
3 votes
4 answers
4k views

Get entries NOT related to categories

is it possible to grab all the entries in a section that arent related to a category? So something like craft.entries.section('news').relatedTo('not',category) Doesnt seem to work but is there some ...
Keith Mancuso's user avatar
0 votes
1 answer
780 views

Reverse Relationships

Doing my first Craft job and stuck with a reverse related entries thing. I’ve got a channel of “Sectors” and a channel of “News”. The entries in news have a relationship field back to the “Sectors”. ...
foamcow's user avatar
  • 2,029
1 vote
1 answer
152 views

Display all related entries in a table

I'm building a site that contains a listing of products and distributors. I have a channel for each, and each entry in the distributors channel contains a relationship field to tie it to any number of ...
artmem's user avatar
  • 1,022
2 votes
2 answers
1k views

How can I use tag slugs in URLs?

This question is a summary of my working with tags yesterday, I'm posting my findings to SE so other people can benefit. For the purposes of this question, I'm going to be using a tag with the title '...
darylknight's user avatar
  • 3,290
1 vote
2 answers
211 views

Organizing repeating content on a single page

I have a page with a slider on it, which includes three rotating slides. In Craft, I am currently setting up each slide as an entry under a "Home Page Content" channel, and then creating an entry ...
patricknoonan's user avatar
1 vote
1 answer
224 views

How to link to prev/next entry depending on related data?

I am quite new to Craft and I am not sure how to get a prev/next link only for entries with related data in a specific field. My situation: I have a Structure (let's call it sourceEntry) with an ...
Arvid's user avatar
  • 292
1 vote
1 answer
166 views

Get Entrys relationships regardless of context

This might be a little complex, but here it goes: Goal: For any given entry, determine where it's located. (Ex. Entry XYZ exists in a news entry, global field, single (page), etc...) Context: So far ...
Fred's user avatar
  • 73
3 votes
1 answer
699 views

Filtering Matrix through field value and multiple relations

I've the following situation: Accommodations (entry) title description (textfield) ... linkedTo (matrix block) Sport (category) targetGroup (category) minimumAge (number) maximumAge (number) What ...
Jaco's user avatar
  • 33
2 votes
1 answer
346 views

Save a selected category for a user (using a plugin)

I have some categories, and with the use of a category field a user can select these from within his / her profile. Which is shown in the image: In my Twig template I can get the user selections out ...
Gary Constable's user avatar
4 votes
1 answer
577 views

RelatedTo Query Using Both "and" and "or"

I'm attempting to build a filter that queries entries of a section based on two criteria: A selection of one or more categories (inclusive), and a single related entry (exclusive). Specifically, the ...
Marcus's user avatar
  • 419
4 votes
2 answers
1k views

Inserting Relationship Into Entries Field - Plugin Not Saving Relation

I was hoping someone could shed some light on this issue I'm having. I'm trying to update a relationship field through a plugin, without much success, the entry looks like this: I saw a post on here ...
Alec Ritson's user avatar
  • 4,539
1 vote
1 answer
349 views

Getting Matrix content from within a relationship field

Here are my channels and fields I need to get to work together. Blog Channel (blog) Matrix Field (bodyMatrix) Gallery Block (gallery) Gallery Field (galleryInclude [entries]) Gallery Channel (...
John Johnson's user avatar
1 vote
1 answer
263 views

Way to getNext() within the same category

I'm trying to get the next and previous entries in a structure but I only want the next or previous ones within the same category? Is it possible to do something like this? {% set next = entry....
Keith Mancuso's user avatar
1 vote
1 answer
151 views

Display entries filtered by one or two related entry fields ordered by "dateUpdated"

I think I have been staring at this one too long because conceptually it seems fairly straightforward but I can't seem to pull it off. I am pretty sure I am going nowhere due to how complicated I am ...
Paulo's user avatar
  • 209
4 votes
1 answer
964 views

Related to entries in categories in a plugin

Ok I can do this in twig but after searching high and low I can't find a good example of how to do it in a plugin. I have a user profile field called interests which holds an array of what they are ...
Lettie's user avatar
  • 2,033
3 votes
0 answers
206 views

How do I traverse relationships when populating models from queries?

I have three models / records - Journals, Issues, and Articles. Articles each BELONG_TO an Issue. Issues each BELONG_TO a journal. Issues have a date on which they've been published, and I am trying ...
Brett Bender's user avatar
0 votes
1 answer
258 views

How do I get all categories with at least one entry [duplicate]

I want all categories that have at least one entry that uses it.
Luke Holder's user avatar
  • 6,837

1
3 4
5
6 7