New answers tagged

2

For info I managed installing the plugin using composer php functions, here's the code : use Composer\Factory; use Composer\IO\BufferIO; use Composer\Installer; use Composer\Json\JsonFile; use Composer\Package\Locker; use Craft; $io = new BufferIO; $jsonPath = realpath(__DIR__ . '/../../../composer.json'); $lockPath = realpath(__DIR__ . '/../../../composer....


3

A simple-ish way you could do this is by using the pre-parse field to parse {{ entry.uid }}. This will then give you an extra column with the unique ID. You can then use Control panel JS to change that into a link/create a button. Something like: $(document).ready(function() { Craft.elementIndex.on('updateElements ', function(data){ if (data....


1

The EVENT_REGISTER_CP_URL_RULES event only fires if you're loading a page in the Craft admin itself. If you're loading your site frontend it won't fire, you need to use EVENT_REGISTER_SITE_URL_RULES instead. You can see the logic around this here.


1

I think you're using Craft 2 syntax. This should work in Craft 3: $vars = ['foo' => 'bar']; // variables loaded into the template $mode = 'cp'; // or "site" $html = Craft::$app->view->renderTemplate('path/to/template', $vars, $mode); return $html;


1

If you don't want to directly embed a Facebook feed using the Page Plugin, you'll have to either use Facebook's API directly or find a third-party service to take care of this for you. Facebook API Take a look at the facebook developer docs to get started. There's an official PHP SDK (library), though it doesn't look like it's supported anymore. The Facebook ...


2

Since 3.4, you do this by passing an array of site ID/site-enabled mappings like so: $entry->enabledForSite = [1 => true, 2 => true]; Where 1 and 2 are your chosen site ids.


2

First, from your field type’s inputHtml() method, make sure you’re passing the field instance to the template as a field variable, and the value as a value variable: protected function fieldHtml($value, ElementInterface $element = null): string { return Craft::$app->view->renderTemplate('plugin-handle/path/to/CustomField_input', [ 'field' =&...


Top 50 recent answers are included