Questions tagged [relatedto]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
2answers
35 views

Sort entries by a related entry (lastName) and then paginate

I have two channels books and authors I need to list all books sorted alphabetically by author. I have this working with the following code: <ul> {# // loop through authors so we can ...
1
vote
0answers
21 views

Showing entries in same category, excluding the current entry

I'm new to this, so sorry if this is really basic. I want to display a list of entries in the same category as the main entry in my template, excluding the current entry. This is my code: {% for ...
1
vote
2answers
16 views

Specific entry type in entry field

This seems like an easy question to answer but I can't seem to figure it out... I'm sure we could do it in Craft 2. Anyway, I'm trying to figure out how to only display a certain entry type in an ...
1
vote
1answer
25 views

Get entries related to selected category only and not it's ancestors

The following is using commerce product entries, but I'm reasonably sure it could be any entry. With the following category taxonomy: - Category 1 - Category 1A - Category 2 - Category 3 ... If ...
0
votes
0answers
17 views

Sort entries by related element in plugin

I am using a plugin to fetch Entry elements based on various criteria (eg to produce an array based on \craft\elements\Entry::find()). The section I am querying features a number of related ...
1
vote
1answer
18 views

relatedTo a category in a matrix field

All, I'm very close, but missing something and any help is appreciated. I have a teamMember matrix block allowing me to add employees with some basic info. One of the fields is a category field called ...
1
vote
1answer
16 views

Pulling blog entries related to a structure entry field type

fairly new to craftCMS. I've wrestled with this now for hours and exhausted all research avenues. I have three main "service pages" (Web Design, Digital Marketing, Hosting & Analytics) These are ...
1
vote
1answer
25 views

Display related entries on the entry page they are related to

I have a number of 'blog' channel entries related to various 'fayre' entries I want to display all the blog entries related to the fayre entry page they are related to (Entry field is 'fayreBlog'), ...
0
votes
0answers
11 views

Getting charges from Charge 2 plugin based on entry field

I setup Charge 2 plugin (v2.3.0) with One-off payment. I have created a custom field with Entry type and associated with Charge content. I am trying to find out charges based on that related entry. I ...
2
votes
1answer
24 views

Getting entries from multiple categories

I have two categories, Annual Reviews and Publications. I want to get all entries from these and paginate them. The code I am using is fine for one category - both work individually, but as soon as ...
1
vote
1answer
35 views

Searching for item SKU in Commerce orders

I'm trying to show some Commerce 2 order information on the front-end. I can't work out the correct syntax. I'm trying to list orders that include a specific product. I have orders for item SKU "...
1
vote
1answer
44 views

Get entries based on multiple fields in controller

I am trying to get the entries based on multiple fields. Fields can be of type tags, checkbox, radio box, and number. In my controller currently what I tried is. $extrafilter will be like Array ( ...
1
vote
2answers
60 views

Related To query

Struggling to get multiple relationship filtering working. So want to filter an entry (people) by one or more of the following: - location (entries) - specialism (categories) - team (categories) For ...
1
vote
1answer
33 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
82 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
219 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
33 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
90 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
61 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
59 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
39 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
112 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
124 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
40 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
111 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
103 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
44 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
157 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
129 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
72 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
281 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
66 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
119 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
30 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
323 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) %} ...
2
votes
1answer
66 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 ...
4
votes
1answer
415 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
34 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 ...
3
votes
2answers
309 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
50 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 = ...
3
votes
1answer
383 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 "...
1
vote
1answer
128 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
142 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
319 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
267 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
18 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
142 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
96 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
272 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 ...