25 votes
Accepted

Why are some entry detail views empty in the control panel?

That error isn't a Craft or PHP error, it's coming from older versions of xDebug. It can happen on more complicated pages (lots of fields, tabs, etc.), but you can get around it by adjusting the ...
user avatar
  • 66.4k
23 votes
Accepted

Can a plugin add JS or CSS to the control panel?

One way to accomplish this is to write some code in the init() function of your root plugin file. So in your example that might look something like: class MyFunkyPlugin extends BasePlugin { ...
user avatar
  • 2,301
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 ...
user avatar
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}
user avatar
  • 66.4k
19 votes
Accepted

How can my plugin generate a generic modal window in the Control Panel?

Create a div with whatever contents you want in the modal, and with a class "modal". Then create a new Garnish.Modal object with it: var $div = $('<div class="modal">...</div>'); var ...
user avatar
13 votes
Accepted

How can I add a RichText-Field to my plugin's CP-section?

To do this you'll need to take a few steps: Load the necessary resources which include the redactor.css and redactor.js file. And if you are using Craft's macros for your fields, the form macro file....
user avatar
  • 13.2k
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 ...
user avatar
  • 1,623
12 votes

Can a plugin add JS or CSS to the control panel?

Josh's answer is great if you are interested in building your own plugin. But if that's a little much for you, you're still in luck... You can use these plugins to quickly & easily add CSS and ...
user avatar
  • 23.6k
10 votes
Accepted

Live Preview XMLHttpRequest error

Instead of allowing cross site access, I'd recommend that you instead just make sure that the site is only accessible through one domain (not both www.domain.com and domain.com). This will also ...
user avatar
  • 7,238
10 votes
Accepted

How can I utilize existing UI for my plugin's control panel views?

Have a look in craft/app/templates for tons of great, easily-reusable examples that make up the existing control panel! They may not be documented, but there's a whole lot of quality stuff there. You ...
user avatar
  • 3,921
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($(...
user avatar
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, ...
user avatar
  • 4,361
9 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()
user avatar
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 ...
user avatar
  • 10.9k
8 votes
Accepted

How to create subfolders in the Assets view?

What you see on the left in the Asset section, are asset-sources and their subfolders. You can configure them in Settings -> Assets -> New Source. In this example, Drinks and Cars are asset-...
user avatar
  • 8,316
8 votes
Accepted

How to tweak login logo position?

You can use this Control Panel CSS plugin to add whatever CSS you'd like.
user avatar
  • 23.6k
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. $(...
user avatar
7 votes
Accepted

Is it possible to change the title of "Quick Post" dashboard widgets?

You can use this Control Panel JS plugin to change the info. Just copy the cpjs folder in the craft/plugins/ folder and the plugin should appear in Settings->Plugins. Install it and add your code ...
user avatar
7 votes
Accepted

Is it possible to reorder globals in the back end?

It's currently not possible to change the order in the control panel, but we might look into that for a future release. They are currently set to display alphabetically.
user avatar
  • 66.4k
7 votes
Accepted

Environment Variable siteURL ignored

In your Control Panel, go to Settings > General. Then set your Site URL to {siteUrl}. This will parse out the siteUrl environment variable. For more information, see this thread...
user avatar
  • 23.6k
7 votes
Accepted

Does Craft Have Publishing Workflow?

You can give a user or a user group the following permissions (on each section separately): Edit entries Create entries Publish live changes Delete entries Edit other authors’ entries Edit other ...
user avatar
  • 1,009
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://...
user avatar
  • 66.4k
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 ...
user avatar
6 votes
Accepted

How can I run the Control Panel from a separate domain?

You can use the baseCpUrl config setting to tell Craft to always generate CP URLs pointing to http://admin.domain.com, and you can create a .htaccess redirect on http://domain.com pointing all ...
user avatar
6 votes
Accepted

Deleting Stale Template Caches Failed

When a task actually fails (as opposed to getting stuck), Craft will log an error message explaining why. To fish it up, open craft/storage/runtime/logs/craft.log, and search for: Encountered an ...
user avatar
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 ...
user avatar
  • 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 ...
user avatar
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"...
user avatar
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 ...
user avatar
  • 23.6k
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 ...
user avatar

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