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
35
votes
5answers
10k 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". [ ...
21
votes
1answer
6k 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, }) %}
17
votes
1answer
5k 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)) %}
17
votes
1answer
942 views

How to show events for “This Weekend, Next Week”

Stemming from this original post I was able to show Events using a custom date field and successfully got "Today" and "Tomorrow" events to show up. How would I go about doing some custom Math to show ...
16
votes
4answers
39k 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 %}
16
votes
3answers
22k views

How to return a specific entry?

Hopefully this is a simple question but I couldn't find a clear answer anywhere - I just want to be able to pull in data from a specific entry, where I know the identifier. In this particular case, ...
14
votes
1answer
3k views

How to duplicate entries

How do I duplicate content within craft? I created one article, and dont want to copy paste content from one to the other, or use one article as template for the others.
12
votes
3answers
3k views

Get an entry's last modified date

Trying to determine if there is a method for getting an entry's last modified date, preferably date-time. Gave a good look over the docs and some searching and couldn't find anything other than the ...
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....
12
votes
1answer
6k views

How to get one random entry from among multiple sections

I'm trying to pull a random entry from among an array of sections, but I can't get it to work. I tried the code below, but I'm just getting errors. I've tried multiple ways of listing the sections -- ...
12
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?
11
votes
3answers
6k 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). What is ...
11
votes
1answer
5k 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 ...
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 ...
11
votes
2answers
2k views

Can I get an entry by Matrix Block ID?

For a url like domain.com/example/123 where 123 is a Matrix Block ID (not an Entry ID), can I get the associated entry for given block ID in a template? Or, for a more general approach, what would be ...
10
votes
4answers
2k views

Delete all old versions from the database

I've been working on a site for a while in beta. The number of versions for all the pages is getting big and the database is now over 2MB. I'd love to just delete all the old versions of all pages ...
10
votes
1answer
4k views

How do I sort entries by two variables?

Currently I am sorting the entries by an ID: {% for gallery in craft.entries.section('Gallery').order('available desc').limit(none) %} but I would like to show the latest entries on top, currently ...
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?
10
votes
1answer
5k views

Advanced query/filter based on date and values

I have a channel of events with a field ‘eventDate’ for the date/time of the event. Within that there are ‘types’ of events ‘eventType’. What would be the most efficient way of outputting the NEXT (...
10
votes
1answer
1k views

Check to see if category is populated?

I want to list all categories that have an entry assigned to them, but hide the ones that are empty. In EE I could do this show_empty="no" But I can't see a parameter in the docs for Craft. ...
9
votes
5answers
1k views

Is there a way to delete all entries in a section?

I've ended up with loads of duplicate entries after a botched import job. Is there an easy and safe way to delete all entries in a section, so that I can start over again?
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 ...
9
votes
1answer
2k views

Exclude multiple entries by their IDs

I have a structure people that I need to grab entries from. However, I need to exclude certain entries as some are already displayed on the page in a different manner. I know that you can exclude a ...
9
votes
2answers
406 views

How would I allow guests to add comments and ratings to existent entries?

I have a page with a bunch of images that I'd like people to rate and comment on. The rating would be a select custom field, and the comment would be a simple textarea custom field. I'd like to ...
9
votes
1answer
3k views

How to list entries related to a category + related to a section?

Sorry if this has been asked before. I've searched for other relatedTo questions but could not find anything similar. I have 2 sections (each having 1 entry type): games reviews Games are linked ...
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 ...
8
votes
1answer
3k views

Ordering Entries without using entry date

Looking to explore solutions for ordering entries in a channel. My current ideas are: For example purposes let's say this is for recipes and the client wants to be able to pick the order of recipes ...
8
votes
1answer
3k 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 ...
8
votes
1answer
386 views

Using Commerce to pay for posting entry

I'm trying to figure out how to do the following: Person registers as new user User creates a new entry with a front-end entry form Entry is saved as disabled so it's not publicly visible User has ...
8
votes
1answer
7k views

Order entries by date field

I have a channel section with a handle named 'events'. In my field layout for this section I have a field named eventsDate, which is a Date/Time field. I also have a plain text field called '...
8
votes
2answers
339 views

Is there any way to set a default status for Entries, either globally or per Section?

The subject more or less covers it — is there any way to set the default status for Entries, either on a Section by Section basis, or globally? I have a client that doesn't want to accidentally set ...
7
votes
3answers
579 views

Can I extend entries listing views (currently or in the future)?

Is there a way to show custom columns in the backend with entries listing views? Or can it be a feature in the future? For example: show category as a column in the news overview in the backend
7
votes
2answers
2k views

Listing categories with post count in a nav?

I'm trying to list my categories (and sub categories, just one sub level) as a nav, and have the number of entries in each of those categories beside each one. There is another question on here which ...
7
votes
1answer
1k views

In Craft 2.5, how can you sort the entry index page by a custom field?

I recently updated a very large site to Craft 2.5. One of the great new features is the ability to view custom fields as columns on the entry index page. Previously, I used the DashCols plugin to ...
7
votes
2answers
544 views

Is it possible to create a fieldtype that creates a many to many relationship between two entry sections?

So, for example: Say I have two sections: - Recipes - Ingredients Recipes can have many ingredients. Ingredients can have many recipes. If I'm editing a Recipe, I can edit the ingredients. This ...
7
votes
2answers
3k views

Frontend upload for images, mp3s and video?

I would like to allow users of our site to be able to upload images, mp3's and video from the front-end. Can I do this with the entry form template easily enough? I was thinking maybe I could use ...
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 ...
7
votes
3answers
771 views

Change default status of entry publication (Lightswitch 'Status')

When I write an article and save it, I want to verify my text. I don't want publish my article immediately. If I'm tired, I sometimes forget to disable the Lightswitch 'Status'. So, how can I disable ...
7
votes
1answer
2k views

Route breaks Single Entry

I'm following the documentation to create a thank-you page when the user submits the form. I have a single created for /contact-us/ and I want the user to be redirected to /contact-us/thank-you/ when ...
7
votes
3answers
1k views

How do I prevent Redactor from wrapping <img> with <p />

I'm looking to have the <img> inserted without the wrapping <p />. I'm assuming I can tie in to one of the callback functions to do this? There is a fileUploadCallback function available ...
7
votes
1answer
838 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
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 ' ...
7
votes
1answer
427 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 ...
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(); $...
6
votes
3answers
11k views

Filter Entries by Field Value

How do I filter a list of entries by the value of a field? For example, if I have a lightswitch field called "Featured", how do I output just the featured entries?
6
votes
1answer
1k views

How do you return a message if no entries are found?

I thought this would be very easy but I'm having a hard time figuring it out. How do you output a warning/message if there are no entries to loop through? {% set entries = craft.entries.section('...
6
votes
2answers
4k views

Structure - Add class if element has children

I have a structure section which I am using to create a navigation menu. It works ok and produces the list etc. I want to add a class to the li element if it has children. Current Code is: {% set ...
6
votes
2answers
910 views

How do I get a random entry's URL from a Entries field?

I have a Entries field and I'd like to return a URL for one randomly picked entry. I could loop through all the entries, but I'd like to do something more efficient. Can I return an array of URLs? Or ...
6
votes
2answers
1k views

Sort entries by most popular

I'm in charge of creating a website with a 'most popular' section. I was wondering if there was any native way/plugin that lets me sort craft entries based on most popular? I know Expression Engine ...
6
votes
1answer
785 views

When deleting a user do the entries they created also get deleted?

We had an instance where a user deleted an admin and it seemed to delete the content that user had created. Is this currently how Craft works? If so is there a way around that without having to change ...

1
2 3 4 5
18