Questions tagged [entrymodel]

The tag has no usage guidance.

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

What's the best practice for creating computed (dynamic/virtual) attributes on entries?

What is the best practice for defining an attribute on an Entry that isn't persistent? For example, I want to create a formatted string from two separate values stored in fields on the entry, but don'...
Tyler's user avatar
  • 11
1 vote
1 answer
118 views

Remove expiration date field from section / entry type

By default, every entry has an expiration date field allowing the editor to expire an entry. I'm currently working on an application with some sections where expiring an entry doesn't make much sense ...
MoritzLost's user avatar
  • 11.2k
3 votes
3 answers
993 views

How to create a new Entry model in Craft 3?

I want to create a new entry for a section named 'drinks'(having section id= 6). The namespace of the file having this code is namespace putyourlightson\userguide\controllers;.I copied this code from ...
jamesSeb's user avatar
1 vote
1 answer
204 views

Can I use Craft CMS as a PIM system?

Does it make sense to use Craft CMS as a Product Information Management system? I have already used Craft 3 for a couple of sites, and I understand part of its capabilities. I was a bit puzzled ...
nitech's user avatar
  • 679
1 vote
0 answers
86 views

Order entries by a matrix field category

I have a lot of trouble in understanding the database/model structure and how to work with the query builder. I tried playing a bit with leftJoins but i cannot seem to make complex queries in craft 3. ...
Dimitri van der Vliet's user avatar
1 vote
0 answers
32 views

modifyEntrySources hook with reverse relations

Is it possible to do a reverse relation query in a custom entry source? https://docs.craftcms.com/v2/plugins/hooks-reference.html#modifyentrysources I have two entry sections, one called courses and ...
James White's user avatar
  • 1,151
1 vote
0 answers
28 views

Recursive relations – how to build list properly?

I started building a list of recursive relations: We're in a project, we want to check interviews related to that project, see which persons participated in those related interviews, and then build ...
Urs's user avatar
  • 639
1 vote
1 answer
165 views

How to get entries with or

it is possible to do like this: $users = Entry::find() ->userLevel('>3') ->or group('admin') So in database level,the sql will go like this: select * from users where users.userLevel ...
yu xia's user avatar
  • 397
2 votes
1 answer
3k views

Programmatically create new entry with saveElement

I am currently trying to save a new entry with craft()->elements->saveElement(), as I want to avoid triggering the onBeforeSave and onAfterSave events. When I run my script, it returns a ...
Alex Glover's user avatar
2 votes
1 answer
632 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 ...
Paul Frost's user avatar
  • 1,060
1 vote
1 answer
175 views

Save Entry Data as CSV and Email it to the Author / Logged in User

I am trying to email some Entry data that they have created in CSV Format to the author/logged in user. I have a controller setup with a frontend form posting an action to the controller: public ...
Graham Winston's user avatar
1 vote
1 answer
195 views

How to detect the model type of an item in an array of query results

When querying multiple model types (entries, Commerce products and Commerce variants) I want to be able to detect the model type of each item as I iterate over the results array. Ideally to avoid ...
amogower's user avatar
  • 113
2 votes
2 answers
303 views

How to improve performance of this nested entries/array template?

I have an event calendar of sorts for music gigs. The back-end has sections for Artists and Venues, where I enter appropriate info, and another section, Shows, which I choose an artist, a venue, and ...
Roger Wilco's user avatar
0 votes
0 answers
84 views

Getting "do not have method or closure named" error when trying to eager load

Below is the full block of code I am working with. This is part of a template for showing all businesses that belong to a sub-category. I need to load all businesses related to the current category, ...
Steven Thate's user avatar
1 vote
1 answer
281 views

Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named

I'm working on a site that was partially built by another dev and am having some trouble with Sprout Forms. It's partially working but when I add a new field (sailSeries) to the template (it exists ...
CreateSean's user avatar
  • 1,963
1 vote
1 answer
671 views

Do slugs absolutely have to be unique?

I know Craft appends slugs with -1 if they already exist but I'm working on an app where the addition makes things awkward for us (we have to match the slug to a third-party service). I was under the ...
Clive Portman's user avatar
1 vote
1 answer
678 views

How to convert this 'array'

With FeedMe I'm importing some data and one of them I get is a complete array that is stored a plain text field. This array is a bunch of car options what I want to add in a table like this: {% set ...
John Stevens's user avatar
1 vote
1 answer
119 views

Force validation on disabled entries

Craft CMS allows you to save entries without any validation if it's not an enabled entry. Is it possible to disable this? I've had a dig through the core Craft code but can't actually find the ...
JamesNZ's user avatar
  • 937
1 vote
1 answer
85 views

Fetching "Pending" Users Related To Entry Within Plugin

This works (but only obtains the active users): // get entry $entry = craft()->entries->getEntryById($entryId); // get existing users in field $entry->customUserField->ids(); So in ...
Jarrett Barnett's user avatar
0 votes
1 answer
230 views

Implementing Revolution Slider

The slider requires an unique ID per slide, wrapped in <li> tags, so I am trying this: <div id="rev_slider_15_1" class="rev_slider fullwidthabanner" style="display:none;" data-version="5.2.5....
Nutmeg's user avatar
  • 598
3 votes
1 answer
1k views

How can I get the locales that are actually enabled for a given entry?

I can use getLocales() off of the entry model to get all locales in the system, and whether they are enabled by default for that entry type, but it doesn't actually return which locales are enabled ...
Jameal G's user avatar
  • 166
1 vote
1 answer
90 views

EntryModel attributeConfigs method throwing undefined index

I am attempting to read out the entry field attributes by using the attributeConfigs array of the EntryModel. When I review the EntryModel object, using id and title as an example. I request the ...
Mark Watson's user avatar
1 vote
0 answers
54 views

Change existing EntryModel custom attribute values [duplicate]

I am trying to change custom field values of a existing entry, but it won't save them in the database. It saves it on the model but the entry isn't persisted to the database. craft()->on('...
Jacob's user avatar
  • 282
1 vote
1 answer
79 views

Model validation not run when using EntriesService saveEntry method

Currently i have to validate my model before saving because of some custom validation rules setted on the model which won't run when using the EntriesService saveEntry method. This causes a two step ...
Jacob's user avatar
  • 282
2 votes
1 answer
3k views

Error: Craft\EntryModel and its behaviors do not have a method or closure named "Case Studies"

I'm new to Craft CMS dev and I'm trying to create a template using Twig and I'm getting this error: Craft\EntryModel and its behaviors do not have a method or closure named "Case Studies" I have a ...
Ross's user avatar
  • 35
2 votes
1 answer
203 views

How to get all (prepped) field values from an entry, indexed by field handle

Getting field values, properly prepped, is covered here: What is getContent() / the ContentModel, and how do I use it to get and set custom field values?
Tim Kelty's user avatar
  • 3,081
3 votes
1 answer
178 views

Why does field value get updated on $element->getContent()->fieldHandle but not when accessed directly $element->fieldHandle?

I am trying to update a custom field on an EntryModel. I'm having half success, and I don't understand why. I've looked at other posts such as this one by Brandon which discuss how to assign these ...
Ben Parizek's user avatar
  • 13.4k
1 vote
1 answer
59 views

Columns on the Entry index page giving errors

For some reason whenever I add a custom column to a section's entry list I'm getting errors and no values. If I add Entry Type to the column list, for example, it's saying: Unknown class: Craft\...
Keith Mancuso's user avatar
1 vote
2 answers
3k views

Deleting all entries from a Section

I'm using Feedme to add entries via an external JSON feed. There was an issue with matching duplicates and now need to remove >4000 entries from the site. To avoid further issues would ideally like ...
Cole Henley's user avatar
  • 1,741
4 votes
1 answer
1k views

How to get the order number of the current entry in a structure

Is there a way in Craft to get the order property of the current entry when it's in a structure? For example say you have the following structure: Parent Page Child One Child Two Child Three Is ...
Gareth's user avatar
  • 1,605
1 vote
2 answers
158 views

Filter Sprout Forms entries based on field value, using parameters

I'm trying to display form entries from Sprout Forms that match a specific criterium: {% for formEntry in craft.sproutForms.entries.formHandle('formHandle').fieldname('fieldvalue') %} {{formEntry....
noregt's user avatar
  • 1,062
2 votes
1 answer
793 views

Paginate entries when I do not have a criteria model?

I have to... merge results from multiple different criteria models use Supersort to order my entries in the desired sort order [...] ...and need to paginate them for my index page. As the paginate ...
carlcs's user avatar
  • 36.2k
2 votes
0 answers
549 views

Updating a single custom field within an Entry

I've got the beginnings of a simple plugin to track views of an article page, just an entry with custom fields including 'dataViews' used below. Within Twig: {% do craft.demoPlugin.incrementView(...
Chris Southam's user avatar
1 vote
1 answer
149 views

How to get rendered image paths from the ElementAPI?

I'm wanting to return HTML content via the ElementAPI. I seem to be able to do this with the following elements.php: 'endpoints' => [ 'api/trials.json' => [ 'elementType' => '...
raggy's user avatar
  • 13
1 vote
1 answer
259 views

Entry saving in task fails due to required assets/matrix fields being read as blank, even through they are not

I have a task that is used to collate relationship data for a specific entry and save it as JSON to a text field in that entry. Everything is working fine, except for the saving of the entry which ...
Tam's user avatar
  • 389
6 votes
2 answers
791 views

Categories field is losing its value when programmatically updating other fields’ values

I have a webhook that fetches an entry, modifies one of its custom Text field values and then saves the entry. However there is also a required Categories field on the entry, and when I do this, I get ...
divinemonkey's user avatar
1 vote
1 answer
136 views

Looping through returns nothing after using dynamic routes to get the entry type and category

I'll explain a bit of the structure of the content and then proceed to the issue. So i have a website with a shop in it with the url mysite.com/shop/, it is an channel section, and its template is ...
Samuel E.'s user avatar
  • 239
7 votes
2 answers
1k views

Get entry index - structure not channel

I want to display the current entry's index - like in this post Get entry index. However my entries are in a structure section type not a channel, so they are not ordered by date. Is is possible to ...
Steph's user avatar
  • 73
5 votes
1 answer
1k views

Get entry by value from custom field

I have a field defined in my plugin called video with AttributeType::Mixed where I store a video_id and a title of a video. I need to look up the entry by the video_id (I can't do it via the the entry ...
augustskare's user avatar
1 vote
1 answer
128 views

How to use a dynamically defined field handle in a plugin?

I'm trying to make a plugin more generally usable (so others could use it). For my own use, it uses a category field called 'mainCategory' but I'd like that the field handle could be specified in the ...
kr37's user avatar
  • 1,355
3 votes
0 answers
697 views

What's the easiest way to update an entry from the front end as a guest user and only post the data that needs to be updated?

I'm creating a multi-page form on the front end of a site where different data is added to the entry depending on the page they are on. Originally I was going to create the entries using P&T's ...
Stephen Bowling's user avatar
4 votes
1 answer
1k views

Saving Entry with Category field

I am stuck on saving entry with a category field. The error message I get is about not being able to create/update the entry in the relations table. $accomodationTypecategory = ['title'=>'Hotel'] ...
Silvanus Matiku's user avatar
2 votes
1 answer
144 views

Pulling Data Across Entry Types

On our play pages (ex. http://actors-express.com.s102768.gridserver.com/plays/liaisons), we list our each of the cast members, their headshot and role. We did this by creating a matrix field that ...
jsilton's user avatar
  • 147
4 votes
2 answers
209 views

Displaying the optional note from a versioned entry

I want to use the note that is optional when saving a versioned entry as part of an activity feed -- like a git commit message. Is there an entry model property for this?
Marc Sexton's user avatar
0 votes
1 answer
878 views

A problem with {% elseif %} statement

Here is my situation. This is not a whole code, only the part, where I'm having a problem. At the back end, model coverbackup is populated with files as well as model cover. If I depopulate cover (...
Dominik Krulak's user avatar
1 vote
2 answers
94 views

Comments being overwritten on save

I am trying to save comments using the core method "entries/saveEntry", but every time I submit the form the last comment is overwritten, is there a simple way of submitting this information to insert ...
ConquestXD's user avatar
15 votes
1 answer
4k views

Is it possible to exclude multiple sections from an entry search query?

I'm trying to build a search function that excludes results from certain sections all together. This is the code I was trying to use. {% set entries = craft.entries.search(query).section('not ...
Allen Pieper's user avatar
4 votes
2 answers
8k views

Determine Entry based on URL Parameters?

I have a bit of code that checks if a page's title has been manually set in a parent template, and if it has to use that, otherwise to use entry.title. This is what that bit looks like: {% set ...
Christopher Healey's user avatar
1 vote
3 answers
1k views

Get the current entry element in the CP (edit entry view)?

You can listen to entries.onSaveEntry or entries.onDeleteEntry events and then get or modify the entry via $event->params['entry'];. But how would I get the entry element and its properties in the ...
carlcs's user avatar
  • 36.2k
4 votes
1 answer
771 views

Is there a way to set a new property on an entry

In a plugin I am creating I want to add a property to some entries. Ideally this property would be hidden from the admin user, as I don't want them to edit it. At the moment I am trying to do ...
mattl's user avatar
  • 330