Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [relatedto]

The tag has no usage guidance.

1
vote
1answer
21 views

How to include a lightswitch for each related entry in the source element of a relationship

I have a Services section in which I keep a related entry field for News. (News by Service) The News items to be displayed for each service are selected in a "News" entries field in the Service entry. ...
1
vote
0answers
43 views

Querying a supertable field

I have an entry type called people which has a superTable field called programmeAffiliations, with three fields, jobTitle, researchProgramme, primary where: researchProgramme is a category field (...
1
vote
1answer
45 views

Order entries by a category field alphabetically then paginate

I've tried so many different things and can't get this to work... {% set makeCat = craft.categories() .group('make') .orderBy('title') .limit(21) %} {% paginate makeCat as pageInfo, ...
1
vote
0answers
24 views

RelatedTo relation - checking matrix block status is enabled

I need to search for all commerce variants related to a custom element "Account". The account element is related to a variant through a matrix field with handle varientaccountmapping, block handle ...
1
vote
1answer
43 views

Multiple and or relatedTo in plugin element criteria

I am trying to return entries that relate to a series of categories. For example, I am trying to return clothing, in this example, I want to return all entries related to (flannel or denim) and (blue ...
1
vote
1answer
46 views

Get entries related to same category

I have a channel (handle: "infopages") with entries. I have a channel (handle: "products") with entries. I have a category (handle: "productTypes") Every entry from "infopages" has a category field, ...
3
votes
2answers
42 views

Showing a list of selected/related categories to entry

I have a suitability category field in my product type that allows the content writer to select which categories this product is associated with. But my issue is that on the product page I need to ...
1
vote
1answer
25 views

Relation fallback if no category has been selected

I have a filter with a few different parameters that get pulled in and I was wondering if there was a relatedTo wildcard that I could use. Here's the relevant code: {% set function = craft.app....
2
votes
1answer
41 views

How to fetch ALL users related to a field, including unverified/pending?

My users have a relationship field called Organisation. In my plugin, I am trying to fetch all users that are related to the organisation I pass it. BUT I would like ALL users including Pending, so ...
1
vote
1answer
83 views

Commerce discount promotions as a fieldtype?

I'd like to create an entry in Craft that talks about a new discount, and then choose that discount via a field (so a bit like you can choose an entry or a product). That way, should the parameters of ...
1
vote
1answer
25 views

Filter entries by other entry

There's a section called locations and another called vacancies. In vacancies the admin can assign a location entry to a vacancy. On the careers overview page we want to display selected vacancies ...
1
vote
1answer
68 views

Fixing deprecated code, relatedTo issue

Working on fixing a lot of deprecated code, enviroment is setup as dev so getting a lot of warnings. Some are easily idetified, others are pretty generic and come from core files. Doesn't show where ...
1
vote
1answer
72 views

Get categories ordered by the associated entries' postDate

I'm looking to show recent categories ordered by their associated entries' postDate. Is this possible? I don't want to list the entries within the category I simply want to list 4 categories that ...
1
vote
1answer
38 views

Pagination: Next/Previous related to author

I'm having trouble limiting next/previous links in one channel to articles by the author. next/previous links are working correctly on the regular blog but when included on the DJ blog I get unknown ...
1
vote
2answers
102 views

Filtering by categories AND tags with full match

We're trying to filter by categories AND tags in the one form. However can't seem to get things working as we would like. Essentially, we have a form that pulls in the tags and allows multiple ...
2
votes
1answer
61 views

RelatedTo “and” and arrays

I have something I can not get my head around. This works as expected: .relatedTo(['and',{targetElement:22},{targetElement:33}]) But when I am building an array to use as relation criteria like so: ...
1
vote
3answers
53 views

Returning entries that contain both categories

I'm creating a filter and would like to return entries that must contain multiple categories (and behavior, not or). A sample url would be /events?cat=2,3. {% set eventCat = craft.request.getParam('...
1
vote
1answer
179 views

Display categories not related to an entry

I'm trying to output a list of categories that are not related to a particular entry (in order to show a list of services other than the service related to the current entry). I have this code which ...
1
vote
1answer
46 views

SQL error when trying to use sortOrder on Matrix related block (Craft 2)

I'm getting the following SQL error when trying to simply order related entries in a Matrix block. Anyway around this? CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity ...
1
vote
1answer
52 views

Edit entry, on the front end, with the entries field

I currently have front-end code working for a user to create an entry, add a title (text input) and also relate entries via the entries field type and checkboxes. All on a front-end application. ...
1
vote
1answer
27 views

Question about “relatedTo”

I want to get list of entries in my section video related to my current entry {% for video in craft.entries.section('videos').limit('3').relatedTo({targetElement: entry.title, field: 'talents'}) %} ...
3
votes
1answer
194 views

Get related posts excluding current post in Craft 3

In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post. I got this far: {% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %} ...
0
votes
0answers
15 views

Trying to paginate from filtered multi-select within a Matrix

I've been trying to paginate some shoes for a store, I've been able to filter inside the loop but that causes gaps, example if one shoe is filtered out I would get 7 shoes on the page instead of the 8 ...
2
votes
1answer
49 views

How to exclude child elements when looping through categories?

I've got a few categories set up with a few child categories for each. Each one has assets (PDFs) assigned to them, by going into the assets, double clicking, and setting the category field there. So ...
3
votes
1answer
200 views

Filtering multiple categories with URL queries

I am trying to filter using categories. I have to filters type and size, in the url. /products.html?size=medium,large&type=polo-shirt,jeans In my template, I am doing the following {% set sizes ...
1
vote
1answer
28 views

Returning entries based on Relationships across different category groups using 'and'

I'm trying to figure out how to set up my relatedTo paramaters to do a category search. Normally it's not a problem but in this case I need something more complex than normal. I have multiple ...
2
votes
2answers
195 views

Reverse relationships with entries and users

I have a relationship between users and 'locations', and I'm using the code below to output some markers for a map. This all works fine except for two things: I'm repeating a couple of 'for' loops. ...
2
votes
1answer
45 views

Can I get entries related to one category from a specific site?

If I can get entries in a category like this: {% set entries = craft.entries.section('sectionSlug').relatedTo('categorySlug').all() %} And a entries from another site like this: {% set entries = ...
4
votes
1answer
258 views

Craft 3 Element API: Query the “parent” entry of a “child” entry with Matrix blocks connected by an 'Entries' field

In a Matrix block field of a "page" entry, I'm using an Entries field to manually select a list of "article" entries to the "page" entry. When I query an "article" entry, is it possible to query its "...
0
votes
0answers
62 views

Searching for multiple tags with the relatedTo parameter's 'and' / 'or' arguments

I'm trying to get the code in this part of the docs—the "Passing Multiple Relation Criteria" section—working, but something's screwy. The mySection section has multiple tag fields. One field has a ...
1
vote
1answer
94 views

Merging Multiple Relations as params

I have the following code where I'm pulling entries related to another entry which works fine. However I also want to limit the entries returned on a category page and thus am merging in a relatedTo: ...
0
votes
0answers
12 views

How can I pull in a related table?

Each of my entries has a table with budget projections. I loop through related entries. But, how can I loop through and bring in the related table? This is my table for the entry: {% set field = ...
1
vote
2answers
91 views

Group entries by Category and then in each category by related entry field

I have a channel with categories and an entries field. I need to first group all entries by their category. This is working fine. {% set entries = craft.entries.section('publicationsChannel') %} {% ...
0
votes
1answer
171 views

Categories Related To Matrix Fields

Please help me build my sandwich locator maker :) I have 3 categories, breads, meats, condiments I have a Section called subShops with a matrix field. My matrix field is called sandwichBuilder, ...
1
vote
1answer
174 views

cannot get relatedTo by slug only ID

Can someone tell me why I am going crazy and cannot figure this simple relatedTo issue out? So I have a categories section called Case Studies and several categories within. I am trying to filter the ...
1
vote
1answer
16 views

List users connected to me

I have a relationship field within my member profile. It allows users to connect to each other, i can list those that currentUser is connected to, but i need to list all other members that are ...
1
vote
1answer
98 views

Include the URL of a related entry field

I would like to add the URL of the channel entry I have selected (atm 2 channels are available to choose from), so I would like a url like: summerhouses/product1 or greehnouses/product2 how would ...
1
vote
1answer
74 views

RelatedTo in plugin based search

$criteria = craft()->elements->getCriteria(ElementType::Entry); $criteria->section = 'stories'; $criteria->search = $this->query; $criteria->order = $this->orderSql(); $criteria-&...
1
vote
0answers
144 views

Category counts for query results

I'm trying to display results from a search. I want to display the categories represented by the search results and the entry count for that category. Think of how Amazon's "refine results" sidebar ...
2
votes
1answer
150 views

Combine Eager-Loading and relatedTo(category)

For a website I'm building for a client I've build a navigation where on hover an image changes dynamically to the image assigned to the entry. See this page for a better understanding: http://...
1
vote
1answer
74 views

Get Related Entries and then filter those by specific category in url segment

Channels: Photographers Photos - entries field handle "photographers" - categories field handle "category" url structure where segment 2 is the photographer slug and segment 3 is the ...
2
votes
1answer
79 views

SEOmatic not merging fields from a related entry

I have a pretty specific set up: posts get created via rss feeds and images are not attached to the specific posts, so instead in the entry template I use an image from a related entry. When I try to ...
1
vote
1answer
71 views

relatedTo working for one category group but not another

I'm trying to show a list of entries related to the same category on a page that contains a single entry. I have two category separate category fields in the entry, both with one category each ...
1
vote
1answer
103 views

Get relatedTo from Neo field

In channel A, we have a Neo field with a couple of different block types, in 1 of those types we have an entries field with channel B entries. On the channel B entry, I'd like to find out if it is ...
3
votes
1answer
200 views

How to get all images from entries including Matrix field

I have a photo gallery that pulls in all entries and then finds the images within them and then displays them along with links to the entries that used that image. Except, it's not pulling in the ones ...
1
vote
1answer
44 views

How to save multiple related entries on the frontend with 1 checkbox?

I have a frontend form and would like to save multiple related entries by checking 1 checkbox. I have this working to save 1 related entry: <input type="checkbox" id="user-type-select-{{ userType|...
1
vote
1answer
282 views

Pass 'not' category.id to relatedTo in Craft

I have a search page that filters with these params: {% set results = craft.entries({ section: 'properties', price: range, search: query.location, relatedTo: status, order: ...
2
votes
2answers
396 views

Multiple category relationship criteria (or)and(or)

Is there a way to do relatedTo categories where the category is (a or b) and (c or d or e)? I can get (a or b) working using: {% paginate craft.commerce.products.relatedTo(categories).limit(20) as ...
1
vote
0answers
106 views

Advanced search entries relatedTo category and unrelated to any category

I know the long-form method for achieving my goal, but I'm hitting a wall in trying to keep the conditionals down. Is it possible to search for entries related to a specific category field AND search ...
2
votes
1answer
314 views

relatedTo currentUser AND entry

I have channel X set up where it's entries have a "users field", an "entries field" (that are picked from channel Y) and a whole bunch of other data with regards to the how a defined user has ...