Questions tagged [entries]

Entries hold the content that you want to display on your web pages. Each entry has an Author, a Post Date, an Expiration Date (if desired), a status (enabled or disabled), and, of course, content.

Filter by
Sorted by
Tagged with
12
votes
2answers
1k views

What are the differences between an elementCriteriaModel and fetched elements?

I am a little confused about the differences between an elementCriteriaModel and fetched elements. Why do I sometimes have to fetch elements with first(), last(), find(): {% set entries = craft....
6
votes
1answer
2k views

Move entry from one structure to another with parenting

Seeing as moving entries between sections isn't supported (yet) through the Craft interface, I followed Brandon's answer for a workaround through the database. I am moving entries from one structure ...
5
votes
2answers
2k views

How to save a matrix content of a new entry in my plugin?

I have a section of type channel with a matrix field. I want to know how I would save the matrix content while I save the entry as well. I know I can save the entry as follows: $entry = new ...
37
votes
5answers
12k views

How can I retrieve channel data in json format?

I've played around with a few implementations but I still don't feel like either is right. I first came across building the JSON itself. This would be in a file at "craft/templates/entries.json". [ ...
5
votes
1answer
1k views

How can I create an ElementCriteriaModel with 'and' and 'or'

In my template, I want to: Get all the entries in the section 'uploads'; Get all the assets that are related to one of the upload entries, and have a relation to all the tags I provide. So, that ...
8
votes
1answer
4k views

Return entries where field is "not empty"

I'm trying to return entries where a specific field named "productSale" is not empty. Unfortunately, my code attempts keep throwing the "Expected name or number" error. Code attempts include: {% set ...
4
votes
1answer
1k views

How do I display a list of assets with the entries they are related to?

Given a list of assets, for each asset, how do I display a list of entries that relate to this asset? So, for instance, if asset A is selected as asset in entries 1 and 2, I want a list to be ...
3
votes
1answer
746 views

Get entries by date but ignore time

I'm trying to pull entries from a database where the postDate is a specific date. {% set today = thisyear ~ "-" ~ thismonth ~ "-" ~ day %} {% set today = today|date('Y-m-d') %} {% set entries = ...
21
votes
1answer
7k views

Exclude Current Entry

How can I exclude the current entry when I've structured my syntax like this? {% set entries = craft.entries({ section: 'blog', order: 'postDate', limit: 5, }) %}
10
votes
4answers
3k views

Infinite scrolling with Craft?

I'm looking to create an infinite scrolling section of entries on a site we're building. Has anyone tackled this yet? What's the best way to approach this?
5
votes
1answer
4k views

Merge two arrays of ElementModels?

I have two queries on related entries (using Many to Many plugin) to find both related and then reverse related entries: {% set relatedArticles = article.relatedArticles %} {% set ...
6
votes
3answers
3k views

How do I enable redactor rich text editor in a front-end form?

I have a front-end form for registered users to submit entries, however I'd like to have a WYSIWYG editor like the dashboard. How would I get redactor working with this form? My form: <form ...
3
votes
1answer
335 views

Dynamic relatedTo queries

I've got an advanced search form which culminates in: craft.entries.section('whatsOn').relatedTo( 'and', { element: artCategories }, { element: locationCategories }, { element: ...
4
votes
1answer
990 views

Paginate Entries by Day

This is giving me a surprisingly hard time. Has anyone tried to paginate entries by date, in this case, specifically by day; i.e.: First page loads today's posts, next page loads yesterday's, then the ...
2
votes
2answers
2k views

Search against a checkboxes field's options

I have a relatively simple structure for products that I am building an advanced search for. I access the products using craft.entries.section('products'), but these products have fields with options ...
2
votes
1answer
675 views

Getting a Single

It appears that getting a entry that is a single is more tricky that it should be. This works, craft.entries.section('footer').first() This does not work, craft.entries.section('footer').limit(1) ...
12
votes
4answers
8k views

What is the best way to exclude an array of entries?

I have done a "Is featured" switch on articles which works great. I can list the latest 4 featured articles but after that I would like to list the others (Of course they may be featured too)...
11
votes
3answers
2k views

How do I set up event listing & detail pages with entry post dates that are in the future?

I'm struggling to set up a listing template and a detail template which will display "event" entries with post date set in the future. I keep getting a 404 error on the detail page. How do I set up ...
17
votes
4answers
49k views

How do I target the first item in a Twig for loop?

I'm looping through some images and want to target just the first image. How do I do that? {% for image in entry.images %} <img src="{{ image.url }}" alt="{{ image.title }}"> {% endfor %}
4
votes
2answers
1k views

Display number based on position in structure hierarchy

I'm stuck. For a new site I need to display numbers before the main h1 title and in the submenu's. Example: 1 Home 2 About 01 history 02 strategy (active page) 03 profile etc. etc. In the active ...
9
votes
1answer
2k views

How do I list entries from a single author?

I'm returning the username as the second segment /blog/username and then setting the username var to craft.request.segment(2). I'm looking to list a group of entries by that author (username). I've ...
4
votes
3answers
868 views

Need to access year/month variable when grouping entries by date

Having issues trying to access the year & month variable when grouping entries by month-year. The code is outputting the desired results (ie. December 2014), however I would like to format the url ...
4
votes
3answers
920 views

Creating comments via a related section

I've been reading on here about suggestions on implementing commenting systems. I'm aware of disqus integration but I want/need built in commenting. I have seen it mentioned a couple of times that ...
9
votes
2answers
2k views

How do I add an HTML block from template extension to main layout template? (i.e. meta data)

I have a main layout file and extending it with another template. I have my markup and content in the {% block content %}{% endblock %} however, I'd like to add content to another "block" on the ...
7
votes
1answer
835 views

Updating an entry after an event action within onSaveEntry

I have written a plugin that checks if an entry has been saved and sends the user an email from within an onSaveEntry event. This works fine. But I now need to also update this entry to flag that an ...
6
votes
3answers
2k views

setContent() vs $entry->getContent()->foo

I'm a bit confused about the usage of these two. Let's say I want to create a new entry from a controller. For me, the nicer option would be to user something like this: $entry = new EntryModel(); $...
2
votes
1answer
1k views

How do I pull related entries and assets?

I'm having a bit of a hard time wrapping my head around exactly how to work with both Relationships and Assets. Here is my current problem that I seem to be stumped on, i'm sure once I get this going ...
7
votes
1answer
2k views

Sorting entries A-Z, ignoring 'The' and grouping by first letter

Probably going to be an easy win for someone here, but being able to do this is currently eluding me. So: I'm trying to output a list of Artist names grouped by first letter but need to ignore 'The ' ...
6
votes
1answer
529 views

How to deal with client input your site?

Our client wants a poll on the website. How can I deal with client input and update the entry? I found the Entry-Form example, but this doesn't work. The title field is the question and the admin ...
5
votes
1answer
666 views

From a template, how can you order entries by one field, and if that field is empty a different field?

Is it possible to put conditions on the ordering of a loop of entries? I have two fields: title and alphaTitle. I want to order alphabetically, by alphaTitle if it has a value, otherwise by title. ...
3
votes
1answer
2k views

Group entries by section

How do I group entries by section? I have search results: {% set entries = allowedSearchableEntries.search(query).order('score').limit(100) %} But I want to have SECTION NAME entry 1 entry 4 entry ...
2
votes
3answers
765 views

Making an entry grid with Batch 2,3 (2 in row then 3 in row)

I'm trying to make a News item grid. I'm looking for a solution to output 2 type of "rows". One that shows 2 entries and the other shows 3 entries. I tried playing around with batches already but can'...
2
votes
2answers
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 '...
2
votes
2answers
2k views

How can I set an entry title automatically, based on a related entry?

If a booking channel contains two Entries fields (one related to a single User, one related to a single 'Event'), how can I get the booking entry title to be set automatically to the following syntax: ...
11
votes
1answer
6k views

craft.entries and lightswitch

This is super simple, and I don't get why it's not working. {% set results = craft.entries.section('events').lightSwitchField('1') %} Returns all entries in Events where the light switch field is ...
8
votes
1answer
915 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 ...
7
votes
1answer
436 views

How Do I show advanced Date filters for Events?

I am trying to setup an events section similar to that of Yelp's Events. They have a listing of all the upcoming events and have filters on the side for "Today, Tomorrow" etc... I received help from ...
3
votes
1answer
4k views

Get entries which have a certain category assigned to them

So, i have a channel called images and a couple of category groups one of which is called "images" which has categories called family, animals, individuals in it. So, i just want to grab the entries ...
3
votes
2answers
185 views

Fire event first time future dated entry goes 'live' from 'pending'

Is there a way I can run some code from a plugin when a future dated entry goes 'live' from 'pending'? I am trying to send an email update that a new entry has been posted. The related post below ...
4
votes
1answer
2k views

Listing categories alphabetically & total post count

How do I list all categories in use alphabetically? And how to get the total post count from each category? Cheers
4
votes
1answer
2k views

Fatal error: Allowed memory size of 134mb exhausted

I have a template in my control panel (technically a plugin, but it's just one template) which is running out of memory: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to ...
2
votes
2answers
596 views

Edit multiple entries at once through the front-end

I am making/trying to make a reservation system with Craft. Logged-in members should be able to make a reservation for a hotel room on the front-end, and change it later. I am keeping a stock for the ...
4
votes
1answer
1k views

In a plugin, how do I save an entry with a related entry

In my plugin, how do I save a relationship when creating a new entry? The example below works for all but the "quiz" relationship. $triviaSet = craft()->entries->getEntryById($data['itemId']); $...
4
votes
1answer
896 views

Group by Field in Matrix Field

Is it possible to group by a field within a matrix field. I have a channel of players which holds their details. I have a structure for teams which includes a matrix field for a Player. The Player ...
2
votes
2answers
1k views

How to exclude entries by type?

I did find this post while looking to do something similar, but I'm beginning to wonder if there's a bug. With code along the lines of: craft.entries.section("pages").type("not landing") I'm ...
2
votes
1answer
413 views

Linking to specific entries in Twig: How performant is Reference Tags parsing?

I have a small menu of fixed entries that forms a sub-nav on a site. I'm currently using Reference Tag parsing to grab links to these entries: <li><a href="{{ '{entry:3666:url}' | parseRefs ...
15
votes
1answer
2k views

Move entries between sections

I have some entries that I'd like to move to a different channel, but I don't see any way to do this. Is it possible?
17
votes
1answer
6k views

Section entries - order by random

I was wondering if it's was possible to order section entries by random. Example: {% for entry in craft.entries.section('team').type('mainPeople').order('title random)) %}
7
votes
2answers
4k views

Do I need a plugin to load entries via AJAX?

I want to load some entries via AJAX. I have a page that normally shows all entries of a specific type with user-selectable filters. I want to load filtered entries via AJAX. Do I need to create a ...
4
votes
3answers
1k views

Display Entries in a calendar

I have a section for holding calendar entries stored by postDate in the CMS. On the front end I want to basically display these in a calendar. I have code which displays the calendar looping through ...