25

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 xdebug.max_nesting_level to something higher than the default 100 or to upgrade xDebug to 2.3+, which has changed to the default value to 256. Note that you don't ...


23

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 { function init() { // check we have a cp request as we don't want to this js to run anywhere but the cp // and while we're at it check for a logged in user as ...


19

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 myModal = new Garnish.Modal($div);


19

There is! It's called cpEditUrl. {% if currentUser %} {% if currentUser.isInGroup('admin') %} <a href="{{ entry.cpEditUrl }}">Edit entry</a> {% endif %} {% endif %} Or shorter (thanks to MISC): {% if currentUser.admin %} <a href="{{ entry.cpEditUrl }}">Edit entry</a> {% endif %} Or forget user group altogether (...


18

To pull off the same functionality in Craft 3, you could use something like this: {entry.last().uri}/{parent.uri}/{slug}


13

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. {% includeCssResource "lib/redactor/redactor.css" %} {% includeJsResource "lib/redactor/redactor.js" %} {% import "_includes/forms" as forms %} Add a class ...


13

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 use of it. Generally speaking, there are plenty of places where you can import/require third party libraries from but my recommendation would be to do so from ...


11

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 JavaScript to your control panel: Control Panel CSS plugin Control Panel JS plugin Disclaimer: I wrote both of those plugins, let me know if you run into any ...


10

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 improve your SEO ranking, since search engines will index both these domains as separate, duplicated content. You can rewrite the domain in your .htaccess, like this: ...


10

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 may also want to consider using macros from craft/app/templates/_includes (Craft TemplatesService doc, Twig macro doc), which will go a long way toward good ...


9

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, a simple settings page will be provided, filled with whatever getSettingsHtml() returns. You can then get the URL from elsewhere in Craft using the ...


8

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-sources: You can add subfolders to each asset-source (and each other subfolder) with Rightclick -> New subfolder.


8

You can use this Control Panel CSS plugin to add whatever CSS you'd like.


8

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. $(document).ajaxComplete(function (event, xhr, options) { if (options.url.slice(-15) === "getMoreElements") { setTimeout(function () { $('#footer')[0]....


7

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 in the textarea displayed at the bottom. Now with your title: In the dashboard, each widget has an ID like widget1, widget2, etc; get it with the dev tools. ...


7

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.


7

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


7

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 authors’ drafts If a user only can "create entries", but not "publish live changes", then he is not able to publish an entry (but he can create the entry).


7

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://buildwithcraft.com/help/cp-languages). If you're running Craft Pro, you can go to Settings->Locales and add (and re-order) new locales to your site. Then you can go to ...


7

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($(this).data('id')); }); Here's an example plugin that will inject it in the CP: https://gist.github.com/boboldehampsink/6bb9e5296977a99c39b1


7

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 from a CP request, you can use siteUrl() instead. (You can also get a CP URL from a front-end request via cpUrl().)


6

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 requests to /admin* to http://admin.domain.com/admin/*, but it is not currently possible to get rid of the CP Trigger segment at this time. Craft relies on that to ...


6

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 error running task Each time the task runner encounters an error, its log message will begin with that, followed by the task’s ID, its type, which step it was on (...


6

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 might want to check is that if the domain you're serving the site (the control panel, specifically), is the same as what you have set in "Settings | General ...


6

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 force trailing slashes (at server level, not Craft's config option) in order to prevent duplicate listings in the client's analytics: # Force trailing slash: ...


6

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 underscores are hidden, similarly, template folders beginning with an underscore hide everything inside.


6

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 needed to do was use the object object to fully utilize twig tags/filters/etc. Here are a few ways to achieve what I was aiming for: {% set num = (object.id * ...


6

Yes there is, craft()->request->isCpRequest() returns whether the request is from the CP or not.


6

If anyone comes here looking for this answer for Craft 3 the function you are looking for is Craft::$app->getRequest()->getIsCpRequest()


6

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 Forge examples) that are known to work with Craft CMS 2.x and 3.x: Nginx-Craft


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