Hot answers tagged

23

When the System Status is set to "off", Craft will return a HTTP 503 response, which will then automatically trigger the "503.html" template in craft/app/templates to load, which is what you're seeing by default. But if you put your own "503.html" in your craft/templates folder, Craft will load that one instead. Same goes for the other HTTP status codes (...


8

You could use craft.app.isSystemOn. This will return 1 if the System Status is "on" in Settings -> General in the control panel. It will also respect the value of the isSystemOn config setting if you're setting it in general.php


7

Live Preview will be available when the following are true: The section’s “Entries in this section have their own URLs” setting is checked The section’s “Entry Template” setting points to a valid template path The entry has been saved It doesn’t matter if the entry is enabled or not.


7

One solution that comes to mind is to add your own custom status field (i.e. 'reviewStatus') as a drop-down menu (or checkbox perhaps if only one status). Then add this field as a column in your list view via a small plugin, using the new modifyEntryTableAttributes hook. public function modifyEntryTableAttributes(&$attributes, $source) { if ($source ...


6

If you're using a Craft Client or Craft Pro, you can save your entry as a draft and review it later. This isn't foolproof either. If you wanted to really try to restrict yourself, you could set up another user account that doesn't have privileges to "Publish live changes." But again, this would require either a Craft Client or Craft Pro license.


6

The getNextSibling documentation says: getNextSibling() will return the next sibling whether or not it’s enabled. If you want to get the closest enabled sibling, you can do this instead: {% set next = craft.entries.positionedAfter(entry).order('lft asc').first() %} Similarly for getPrevSibling to get the previous enabled sibling you can do: {% set prev ...


6

You can check the status of an entry with .status. https://craftcms.com/docs/templating/craft.entries#status This code should work! {% set jobsEntry = craft.entries.id(jobsId) %} {% if jobsEntry.status == 'live' %} <a href="{{ jobsEntry.url }}">Jobs</a> {% else %} Jobs is disabled {% endif %}


5

This isn't exactly an answer, but more of an extension of Brad's answer. The docs define what an entries status can be. So as Brad was saying the status itself cannot be set, but: if the entry is enabled + has valid post date + has not expired = status is enabled. I found your post because I was also setting enabled->true but my entry was not getting ...


5

Not directly, but you can indirectly change it. An entry's status is defined by several attributes. An entry is considered "live" if it is enabled (both on a per-locale and global basis), it has a post date in the past and an expiration date that doesn't exist or hasn't been met yet. If the entry is enabled and the post date is greater than the current ...


4

You can get all entries regardless of status with .status(null): {% set allEntries = craft.entries.section('sectionName').relatedTo(category).status(null).find() %}


4

You would first query for all active categories and then get the Product entries that are related to these categories. {% set allCategories = craft.categories.group('Categorie') %} {% set entriesWithActiveCategories = craft.entries.section('Products').relatedTo(allCategories) %}


4

Douglas has posted a great suggestion about creating an additional custom field for "Status". But I think it's also worth mentioning Josh Crawford's great free plugin called Workflow which takes Craft's built-in permissions a step further with: User interface improvements, including a button to "Submit for Review" Email notifications to notify publishers ...


4

Just an updated version of Marion's answer for Craft CMS 3 since order and first are deprecated. {% set prev = craft.entries.positionedBefore(entry).orderBy('lft desc').one() %} {% set next = craft.entries.positionedAfter(entry).orderBy('lft asc').one() %}


4

You need to include a hidden field with the value of 0 before the checkbox to ensure that the value is included in the form data if the checkbox is unchecked. See the docs on templating for checkbox fields. So you'll need to have this in your form: <input type="hidden" name="enabled" value="0"> <input type="checkbox" name="enabled" id="enabled" ...


3

The "status" on an entry isn't explicitly set like that. It is determined based on other properties of the entry. You will need to set these other criteria for the entry to appear as "pending". An entry is 'pending' if it is enabled and has Post and Expiration Dates in the future. More information on status' and the criteria can be found on the docs. ...


3

As of Craft 2.6.2771, sections now have a “Default Entry Status” section.


3

If you're specifically checking for the admin, then it's more like: {% if currentUser.admin %} {% set slug = craft.request.lastSegment %} {% set entry = craft.entries.slug(slug).status(null).first %} {{ entry.title }} {% endif %} If you're getting a 404, then it's some other routing issues that is occurring.


3

Try to set both states in single/double quotes: {% set allEntries = craft.entries.status('live', 'pending').section('sectionName').relatedTo(category).find() %}


3

status('disabled') should do the trick for you 👌 {% set entries = craft.entries() .section('profileEntry') .status('disabled') .all() %}


2

Grab all of the entry IDs you want from the craft_entries table, then find the rows matching those IDs in the craft_elements table and set their enabled column to 0 to disable them en masse.


2

This works: {% set user = craft.users.id(craft.request.lastSegment).status('pending').first() %}


2

I don't think you can disable categories with the current version of Craft. But you're right, it currently looks like that categories are prepared to get disabled. Update: Categories now have their own edit pages in Craft 2.3, where you can set the status. And you can even set it on a batch from the category index page!


2

On localized sites, each entry has two statuses: the primary entry status (the big “Status” lightswitch field at the bottom of the sidebar) and the locale-specific statuses (the small lightswitch field beside the currently selected locale). For an entry to be enabled, both of those lightswitches have to be turned on. But only one of them has to be turned ...


2

I agree this is confusing. If you are editing the entry, you can change the status per/locale by selecting the locale in the box in the upper right corner, and then using the lightswitch next to the selected locale.


2

I ran into the same problem where if a page was 'disabled', I didn't want it to show in my footer navigation. The recommended answer didn't work for me. The link still showed up. The following worked: {% set myEntry = craft.entries.id(entryId).first() %} {% if myEntry %} <li><a href="example.com">Example</a></li> {% endif %}


2

There are a couple of aspects to consider in your question. Display entries to the author who created them Display entries which are disabled I'll assume your Channel/Structure is named "Gallery Image"... First, establish the User ID of the logged in User: {% set loggedInUserID = currentUser.id %} ...then find Entries authored by the Logged in User: {% ...


2

As you've discovered, you should be using the more generic elements.onBeforePerformAction or elements.onPerformAction events. They get fired when any action takes place and you can check their action parameter to determine if it was a SetStatus action.


2

I guess it is either a bug or the developers don't want us to do it via cp request. In my plugin (phpCode) I can activate and deactivate categories per site easily but the cp template is missing the required input. When you compare the route of a category and an entry you'll notice it easily Take a look at entries/_edit.html <ul id="sites" class="pane"&...


2

In your Courier Blueprint listen to entry.beforeSaveEntry events and use this code for the Trigger Condition: {% set oldEntry = craft.entries({ id: entry.id, status: null, }).first() %} {%- set wasDisabled = oldEntry.status == 'disabled' %} {%- set isEnabled = entry.status == 'live' %} {{- wasDisabled and isEnabled ? 'true' : 'false' }}


2

Why don't you just grab disabled entries from the author? {% set entries = craft.entries .section('profileEntry') .status('disabled') .authorId(currentUser.id) .all() %} Then you can loop those {% for entry in entries %} {{ entry.title }} {% else %} no entries found {% endfor %}


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