28

This is the correct way. Examples: Singles: {% set entry = craft.entries.section('section_handle').first() %} Channels / Structures: {% set entry = craft.entries.section('section_handle').slug('my_slug').first() %} General: {% set entry = craft.entries.id(5).first() %} See craft.entries for a list of all properties.


28

The trick is to add and once before the first not {% set entries = craft.entries.search(query).section('and, not this, not that') %}


22

Have you switched sorting to "Structure"? When you're not sorting by Structure, you won't be able to rearrange the entries.


19

According to the docs, you can pass an array into the "section" parameter: {% set entries = craft.entries.section(['quotes','didYouKnow']) %} There are several ways to get a random entry, but the method you've chosen is a very good one, because it randomizes during the initial SQL call: .order('RAND()') Lastly, you can cut out some of the extra legwork ...


18

One thing that’s important to remember is that there’s no inherent relationship between your templates and sections. Any template can show any entry from any section. So there’s no such thing as the “current section”. If your section has the “Entries in this section have their own URLs” setting checked, and you’re requesting one of that section’s entries’ ...


13

Create a Single called "Blog Overview" and set its URI to "blog" and its "Entry Template" to "blog/index" (your blog listing template). Then just override the title to "Blog" either by hard coding it in the index template, using an "title override" field, not showing its title etc.


13

It’s currently only possible via direct manipulation of the entries in your database. You will first need to visit your sections table to determine the desired section ID, and then the entrytypes table to determine the desired entry type ID. Once you have those, find your entry’s row in the entries table, and change its sectionId and typeId columns ...


11

There's no such method available for craft.entries, at least it's not documented. But you can use craft.sections to get an array of section models and filter them with a conditional within a loop: {# Get all Section #} {% set sections = craft.sections.getAllSections() %} {# Loop through all single sections #} {% for singleSection in sections if ...


11

The primary parameter you're looking for is lft: craft.entries.section('volumes').order('lft desc')


11

I don't know if its possible to be much clearer than the official docs on this matter, but basically a Structure is needed if your entries needs to be in a specific order (and you want to manage that order w/ an easy to use, drag-n-drop interface within the Control Panel), or if they need to be nested (i.e. hierarchical, with parent/child entries). The ...


10

A simpler way to do this might be: {{ entry.type.name }}


10

A safe way to add JavaScript resources via the frontend, is to use the {% includeJsFile %} Twig function in your template. The nice thing about the includeJsFile function is that it doesn't matter where in your template you call it; the file(s) added will always be output just above your </body> tag (or wherever else you put your {% getFootHtml() %} ...


9

I recently setup a structure which contains (almost) every page of my site. When I set it up, I specified only {slug} as the URL. So far, it's working fantastically! And that's with about 30-40 pages created in the structure (some nested within others).


8

Classic find the answer straight after posting. The getEntryTypes method of the sections model allows you to choose how the array is indexed. This means you can do this: {% set entryTypes = section.getEntryTypes('handle') %} Which means our entry type model can be accessed using: {% set entryType = entryTypes[routesEntryTypeHandle] %} And the name: {{ ...


8

You could try using use the reverse twig filter. {% for entry in craft.entries.section('volumes')|reverse %} ... {% endfor %}


7

The current answer to this is no, not out of the box. The unofficial answer to this is, it has been discussed several times out there in the forums and there are some good arguments to make that this is a core part of 'content management'. The developer-friendly answer to this is yes, you can control those columns if you create a plugin with a new Element ...


7

For anyone stuck on this -- when changing a Section's name you have to goto the entry under Entries and hit save. This will update the mysql row / title.


6

I'm not sure if you can set a default entry type within Craft. But a reasonably workaround would be to go to Settings > Sections, then click 'Edit entry types' for the section you need to apply this to. Next, drag the entry type you would like to be used by default to the top of the entry-type list. That way, when a new entry is added to the Section, the ...


6

The url's are always bound to entries. And with your current code, you're getting all entries in the 'contact' section, not the section itself. But if this is a single, what you want is the url of the entry in the 'contact' section. Try this: {% set contactPage = craft.entries.section('contact').first() %} {{ contactPage.getUrl() }}


6

You can place your homepage entry in a Structure by setting its slug to __home__. Doing so causes the entry to answer for the / (empty) URI, and it even places the little "home" icon in place of the Entry's slug in the CP. However, if you do this, its best not to nest pages under the homepage, because then their URIs would be of the form: __home__/...


6

I'm not familiar with ACF, but if you're looking for blocks-within-blocks, you could use the Neo plugin/fieldType. It allows you to define blocks, and then have nested blocks. It allows for decent management of blocks, too, so that you have children of specific parents. For example: You could have the following blocks/content types: Copy Card Image ...


6

From the official docs: Channels are used for streams of similar content Structures are good for times when you need to store multiple similar entries, and they need to be sorted into a specific order. They can also be hierarchical. As per your question there's no performance overhead involved, but as a general rule it's usually a good idea to ...


6

This should work: $section = craft()->sections->getSectionByHandle('sectionHandle'); $sectionId = section->id;


6

You can use {{ craft.entries.section('whatever').total() }} for that.


5

Sections are for completely separate areas of content. They have their own URLs, and are conceptually different. Like blog posts and press releases would be different sections. Your sections could easily be one section with a different set of categories defining web development and general writing. This is entirely up to you. Categories are for separating ...


5

The entries won't immediately get updated, as it could take a little while to go through all of them, but you should see a little progress bar in your CP header immediately after updating your section's settings, and if you click on it, it will give you more details -- saying that a "Resave Elements" background task is running. Once that has completed, your ...


5

There is an nice recipe on the craftcookbook.net site from sprocketeer that explains exactly this. {% set topEntry = craft.entries.depth(1).slug('information').first() %} <ul> {% nav subEntry in topEntry.getDescendants() %} <li>{{ subEntry.title }} {% ifchildren %}<ul>{% children %}</ul>{% endifchildren %} ...


5

Short answer – no, there isn't any way to add a dropdown for template selection to Sections without modifying the core (which is never a good idea). Beyond that, its difficult to advice without a brief description on what you're attempting to build. Craft is generally perfect for flexible, modular content and layouts, and what you want to achieve is most ...


5

I like what Matt P wrote in his answer: try to consider how someone [else] will find the logic of the CMS design The other factor you want to consider in information architecture is you only want store data once in the database. So how you intend to pull that data out also is going to influence your decision on how you store it. The good news there is ...


5

Best is to create fresh Craft instalation and experiment, learn basics. I did the same thing when I was assigned to a large drupal project. Here is a resource list on Craft: http://craftcookbook.net http://straightupcraft.com/articles/getting-started-with-craft-cms http://webdesign.tutsplus.com/courses/building-landing-pages-with-craft-cms http://craftcms....


Only top voted, non community-wiki answers of a minimum length are eligible