18

If you go into your Category Group’s settings and set the following settings: Craft 2 Top Level URL Format: {slug} Nested URL Format: {parent.uri}/{slug} Craft 3 Category URI Format: {parent.uri}/{slug} then you would be able to set your section’s Entry URL Format to this: Craft 2 {myCategoryField.last.uri}/{slug} Craft 3 {myCategoryField.inReverse()...


14

{% set entries = craft.entries.section('pages').type('blogPost') %} {% for entry in entries %} {{ entry.title }} {% endfor %} Is what I have cobbled together... any pointers on improvements would be welcome.


13

Even if you set the limit to 1, Craft always returns an array of entries. So you need to add first() to access the first (and only) entry. {{ entry.buttonTargets.first() }} It you don't add a property, this returns the entry's title by default. So you additionally need to add url to output the URL of that entry. {{ entry.buttonTargets.first().url }}


11

You can set the ElementCriteriaModel's type parameter to multiple values by passing it an array of entry type slugs: {% set teachers = craft.entries.section('teacher').type(['teacher', 'demoTeacher']) %} Use the type property on the entry model to access its entry type in your conditional (also see this list for other available properties). {% for teacher ...


11

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


11

Sure just do this discography/{type}/{slug}


10

You could just set your "Entry URL Format" to: my-section/{type.name}/{slug} Your entry type names couldn't be as clean when composing entries in the CP as you'd need to set them to something like "example-entry-type", but it would work. Now for the really clean way: Install the Low Regex for Craft plugin. Set "Entry URL Format" to: my-section/{type....


8

craft.entries() fetches entries. To fetch the entries with a given entry type, you use type. So to get the Article entries, either craft.entries.type('Article') or craft.entries({type: 'Article'}) To fetch the latest 5, you want the entries sorted by postDate, descending (this is the default sort order), and then limit that to 5. Combining with the entry ...


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

Alright, I was able to figure it out myself: channel{% if object.type == 'xyz' %}/{type}{% endif %}/{slug} produces the desired results. The section for Dynamic Entry Titles in the docs pointed me into the right direction.


8

At the moment loop.first and loop.index0 are relative to your block.image loop. If you want them to be set based on your entry.locationSlideshow loop (the parent loop) you can use {{ loop.parent.loop.index0 }} and {{ loop.parent.loop.first }} For more information see the Twig documentation.


8

A little bit late but here it is. Go to https://pluginfactory.io/ and create a plugin, you need at least 1 Controller but you can leave the Name value blank to create a controller with the same Name as your PluginHandle. So if you choose "Experiment" as your Pluginhandle your controller will be ExperimentController Click on "Build my Plugin" and save the ...


7

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 ...


7

No, you still have to set the parameters by your own: {# Get this entry's entry type #} {% set type = entry.getType() %} {# Set parameters for prev/next elements list #} {% set params = craft.entries.section('blog').type(type) %} {# Get the prev/next elements #} {% set prevEntry = entry.getPrev(params) %} {% set nextEntry = entry.getNext(params) %} {# ...


7

I eventually figured this out. Here's the code that's working for me: $newFields = array( 0 => '12', // $field->fieldId 1 => '15' // $field->fieldId ); // First we get all sections and loop through them $allSections = craft()->sections->getAllSections(); foreach ($allSections as $section) { // Then we get all EntryTypes of each ...


5

You can get the entry’s current type handle via entry.type, and craft.entries supports a type param for finding entries of a given type, so you can plug those two together: {% set otherEntries = craft.entries.section('blog').type(entry.type) %}


5

Yes. This is certainly possible. I'm not sure how you're templating / naming is setup but you can get entries by entry type and you can check an entry's type. To get entries by a specific type: craft.entries.section('blog').find({type: 'imagePost', limit: 10}) Here's some helpful references for craft.entries: Entries Cheat Sheet - Craft Docs For the Entry ...


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

You can have entry type specific templates for your entry pages, see this docs article on how you can do this. And for your archive pages, just set a route for each of them and point it to the corresponding index/listings template. So basically you end up with something like this for your entries: media/_entry.html (example.com/2014/01/01/example-entry) ...


5

Sounds like you're looking for something like this: https://craftcms.com/support/entry-type-templates


5

It is not possible to have dynamic tags within Entry Template settings, no. All fields that do allow dynamic tags will say so in their instruction text. The reason it’s allowed in some settings but not others is because there is a performance hit each time those dynamic settings are rendered. (We actually spin up Twig to do the parsing, but since the ...


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

Take a look at the sections documentation: https://craftcms.com/docs/templating/craft.sections The following code lists all entrytypes of all sections. {% set sections = craft.sections.getAllSections() %} {% for section in sections %} <h2>{{ section.name }}</h2> {% set entryTypes = section.getEntryTypes() %} <ul> {% ...


4

The reason why your example fail is that you are using the entry variable. You are trying to call the function getUrl on the model entry, but the function (or model) doesn't exist yet, and has to be created (fetched). Example: You can use craft.entries to fetch the EntryModel, and than output its url: {% set my_id = 5 %} {% set entry = craft.entries.id(...


4

Try using a structure. You can reorder them in the CP. {% for entry in craft.entries.section('your_structure') %} {{ entry.title }} {% endfor %}


4

This has been solved via a support ticket, which I'm posting here for others etc. The first time you load the template, the URI is mapping to your "Get A Quote" entry, which gets assigned to the entry variable when your template is loaded. When you submit the form, the same URL is requested again, once again matching your "Get A Quote" entry, ...


4

To access related entries stored in a matrix field, you need to specify the targetElement (actor/entry) and the matrix field (using dot syntax 'matrixFieldHandle.entriesFieldHandle') from 'plays'. In your actor biography template: Actor: {{ entry.title }}<br><br> {% set plays = craft.entries.section('plays').relatedTo({ targetElement: ...


4

This question is old, but the solution is: // look up parent with a ElementCriteriaModel $parentCriteria = craft()->elements->getCriteria(ElementType::Entry); $parentCriteria->search = 'slug:'.$parentSlug; // whatever you have $parent = $parentCriteria->find()[0]; $entry = new EntryModel(); $entry->sectionId = $section; $entry->...


4

{% if not entries %} never executes, even if i enter complete nonsense in the url. You’re not ensuring that segmentCategory is a valid category slug anywhere. If it’s not, then category will get set to null, which will basically prevent it from affecting the following relatedTo param. So right after grabbing the category you should make sure it exists; {% ...


4

Yes that makes sense. There are many ways to approach this. I always try to consider how someone other than me will find the logic of the CMS design i.e. How easy will they find Craft to actually use without me? To make the most of what you already have, consider adding a Users custom field to your Leadership entry type. This would allow you to select the ...


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