21
votes
Accepted
Get Entry Edit Link in Twig
There is! It's called cpEditUrl.
{% if currentUser %}
{% if currentUser.isInGroup('admin') %}
<a href="{{ entry.cpEditUrl }}">Edit entry</a>
{% endif %}
{% endif %}
Or ...
- 13.4k
20
votes
Accepted
{parent.uri}/{slug}
To pull off the same functionality in Craft 3, you could use something like this:
{entry.last().uri}/{parent.uri}/{slug}
- 66.8k
13
votes
Accepted
Plugin Dev - Load third party library
I second Brad on this, if there is a composer package, use that.
Whether you use a composer package or a library not found on packagist.org you'll still need to load it so that your plugin can make ...
- 1,623
10
votes
Accepted
Possible have matrix rows collapsed by default in the Control Panel?
Inject this piece of JS in your CP and they will always be closed by default:
$('.matrixblock').each(function() {
$(this).addClass('collapsed');
Craft.MatrixInput.rememberCollapsedBlockId($(...
- 1,173
10
votes
Is there a way to detect if a action is triggered from a control panel form?
If anyone comes here looking for this answer for Craft 3 the function you are looking for is Craft::$app->getRequest()->getIsCpRequest()
- 820
9
votes
Accepted
Linking to a plugin setting page?
Add a public getSettingsUrl() function to your main plugin file that returns a URL string.
A full URL is not required -- you can simply return "pluginname/settings".
If this is left blank, ...
- 4,371
9
votes
Why is the cpresources folder so big?
Craft CMS 3 uses Yii2 Asset Bundles for AdminCP resources. This lets it handle dependencies such as certain scripts not loading before jQuery, for example.
Remember that many Craft CMS 3 components ...
- 11.3k
8
votes
Accepted
Possible to speed up infinite scrolling?
You could open up the console and paste this then scroll to the bottom once.
After that, this will keep scrolling to the #footer every time a response from the getMoreElements request comes in.
$(...
- 962
7
votes
Accepted
Change system language
If you're running Craft Personal or Client, you'll need to go to the craft_locales table in your database and change the locale to one of the support Craft control panel translations (http://...
- 66.8k
7
votes
Accepted
Twig url() function returns CP path when called from plugin
Right, url() (and UrlHelper::getUrl(), which url() maps to) will create a URL to either a front-end page or a CP page, depending on where it is being called from.
If you want to get a front-end URL ...
- 33.9k
6
votes
Live Preview not working
Just want to mention for anyone running across this thread that if you're having a problem with live preview and seeing dev tools errors of the nature of cors or crossdomain then the first thing you ...
- 179
6
votes
Live Preview not working
Another cause of Live Preview not working that can be a pain to debug, because there are no 'errors' as such is your .htaccess setup. For example, on one site we had the following .htaccess entry to ...
- 614
6
votes
Trigger Task Status Icon
I use this to force the task icon to show up immediately:
Craft.cp.setRunningTaskInfo({
"id": "task ID",
"level": "0",
"description": "description",
"status": "running",
"progress"...
- 1,173
6
votes
Prevent ALL templates from being rendered directly?
This is very, very simple to do... just put every single template into a specific folder, then prefix the folder with an underscore:
/craft/templates/_everything/
Template files beginning with ...
- 23.7k
6
votes
Accepted
Show field handles on control panel
Original answer, for Craft 2:
There's a plugin called CP Field Links which will display field handles and provide easy access to field (and entry type) settings. Please note that the plugin requires ...
- 21.4k
6
votes
Accepted
How do I properly use Twig syntax in dynamic title/URL fields?
After chatting with The Honorable Brad Bell I learned that the sample tags in the field's label are showing some shorthand references to a few variables. (The {slug} reference for example.)
All I ...
- 191
6
votes
Accepted
Is there a way to detect if a action is triggered from a control panel form?
Yes there is, craft()->request->isCpRequest() returns whether the request is from the CP or not.
- 36k
6
votes
/admin/actions/users/login 404
What server provisioner are you using? Forge? Something else? If it's Forge, it's most likely this:
https://twitter.com/nystudio107/status/895726366477344772
Also here are some Nginx configs (with ...
- 11.3k
5
votes
Accepted
Can I disable the control panel?
Good call Brad! Not sure why that didn't occur to me :)
Here's how that's done:
# Kill admin access
RewriteCond %{REQUEST_URI} ^(.*)/admin
RewriteRule ^(.*)$ - [F,L]
- 281
5
votes
Accepted
Can I add another filter option to element index views?
I made a small plugin that nests Entry Types under their section in the sources list that might be good enough for what you're after:
https://gist.github.com/mdcpepper/548fd04939e040507960
- 4,371
5
votes
Setup default Matrix blocks and default values for sub-fields?
It's not possible to have default values for most field types and it is also not possible to have default matrix block already added to your new entries.
If there was an event that gets raised before ...
- 36k
5
votes
Plugin to "check/uncheck" all matrix blocks while editing entries?
There's a related feature request for this: "Expand/collapse all" UI for Matrix fields
In that feature request, Brandon Kelly explains how this is already supported (it works very well):
There is ...
- 36k
5
votes
Accepted
Adding additional attributes to modifyEntryTableAttributes()
See this question:
Possible to add category field to modifyEntryTableAttributes?
Basically, you need to use the getEntryTableAttributeHtml hook to get the actual content to the table cells in ...
- 433
5
votes
Accepted
Change field arrangement from the entries page
No, that's not possible with Craft at the moment (2.4). You'll have to use the Field Layout Designer from Settings -> Sections -> {Section} -> {Entry Type} to manage your fields and tabs.
You could ...
- 21.4k
5
votes
Accepted
Disable modification of assets title and name
I guess this feature request will solve my problem... in the future:
http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7197199-ability-to-hide-or-disable-fields-based-on-a-...
- 972
5
votes
Accepted
Filter entries by entry type in the CP?
What you can do is to create additional entry sources using the modifyEntrySources hook.
This is a very simple example, that will add a heading and two sources to the end of the
sources list (below ...
- 36k
5
votes
Accepted
Is there a way to see the total number of entries in a channel in the CP?
You're looking for the Content Stats plugin by Will Browar:
https://github.com/wbrowar/contentstats
- 23.7k
5
votes
Cannot enable Craft plugin in control panel
My guess is it's a case sensitivity issue with the main plugin class/file name (some operating systems have case sensitive filesystems and some don't).
You can review the requirements for how things ...
- 66.8k
5
votes
Accepted
How can I add images to field instructions?
This works with standard markdown code...

You can use either a full URL, or a local path to the image.
- 23.7k
5
votes
Accepted
Customize Admin Sidebar Menu Items?
Craft does not offer this functionality natively. Luckily there's a few plugins out there that will help your users navigate around a bit easier:
In the CP Nav
https://github.com/engram-design/CPNav (...
- 749
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
control-panel × 415plugin-development × 62
craft3 × 37
entries × 34
assets × 27
admin × 27
users × 25
plugins × 19
templating × 18
login × 16
matrix × 13
error-message × 13
search × 12
localization × 11
config × 11
categories × 10
permissions × 10
field × 9
entry × 8
session × 8
cp-dashboard × 8
redirect × 7
performance × 7
language × 7
garnish × 7