Skip to main content

Questions tagged [hook]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
39 views

Saving metadata for asset when uploading file

I'm trying to set the value of a custom field for an asset while uploading the asset. But somehow the value is not being saved. I can see the data in the EVENT_BEFORE_SAVE and EVENT_AFTER_SAVE hook, ...
thomasjonas's user avatar
1 vote
1 answer
95 views

Set default values for new Commerce products

I'm trying to set some defaults for newly created products. That is, when a new product is created, I want to set some settings to specific default values, but users should be allowed to change those. ...
MoritzLost's user avatar
  • 11.5k
2 votes
1 answer
447 views

Adding Custom button to CP

I'm trying to add a custom button in the sidebar of one of my entries. I've found that it could be done in Craft 3 with this template hook: cp.entries.edit.details (e.g. How to add a custom button at ...
Robin Gauthier's user avatar
0 votes
1 answer
134 views

How to add Field to Template hook cp.entries.edit.settings and save value to entry?

I'm trying to show a custom lightswitch field inside the right panel on the edit page of an entry and saving its state to the entry when the user clicks on save. My form template looks like this: <...
Martin Lüpold's user avatar
0 votes
1 answer
101 views

Craft 4: How to programmatically attach a new tab in elements tab?

I'm trying to add a new Tab in entry elements from my module using events. Event::on( FieldLayout::class, FieldLayout::EVENT_DEFINE_NATIVE_FIELDS, static function(...
Amsal Situmorang's user avatar
2 votes
1 answer
190 views

Apply custom filter on the entries in admin control panel using custom plugin in craft cms 3.5

I was referring to Filter entries in the CP based on custom permission and Filter entries in the CP based on custom permission It seems onBuildElementsQuery was available only in 2.x. Is there any ...
Ram's user avatar
  • 41
1 vote
1 answer
77 views

Removing the Save button based on some condition

I want to remove the Create button of an entry based on some condition (review states) for some users. Is there a way to hook in within a module?
Slowwie's user avatar
  • 235
2 votes
1 answer
281 views

Help understanding hooks

I need to build a plugin or module that hooks into the Sprout form upload file function so I can add text programmatically to the user uploaded filename. I've had input before that I should work with ...
JJefferyDev's user avatar
1 vote
1 answer
63 views

How html title is generated in entry index page in CP

I am trying to find out how HTML title is generated in entry index page in Control Panel. i know it is generated in src/templates/_elements/element.html file by $this->hook('cp.elements.element',...
user9975's user avatar
  • 534
1 vote
0 answers
28 views

How to modifyPaymentRequest() in Commerce 2?

Looks that I really used every functionality in my plugin that changed or has been removed in Commerce 2. :( I need to modify paypal transactionId and description what i did as follows in Commerce 1: ...
phaetons's user avatar
  • 705
1 vote
1 answer
538 views

Webhook plugin & hooking into Contact Form

As my first delve into webhooks I've just installed the Pixel&Tonic Webhooks plugin. I'm trying to send data from a front end contact form to Zapier. The front end form uses the Pixel&Tonic ...
Dr_Codswallop's user avatar
1 vote
1 answer
161 views

Can you hook into a Redactor field before render?

I am wanting to hook into all my redactor fields content before rendering and update any inline links to include a title="" attribute. Is it possible to hook into the field before it is rendered? With ...
Hector's user avatar
  • 187
1 vote
1 answer
727 views

Getting current entry element via plugin in Craft 3 without a hook

Is it possible to query the current entry or category element via a Craft 3 plugin/module? In the 2.6 era, I would use a hook. The Craft 3 iteration of a hook looks something like this: $...
Mark Notton's user avatar
  • 2,337
1 vote
1 answer
141 views

How do I edit a dropdown field in the charge.onCharge hook?

I have an invoice that is sent to stripe to be paid. When the thanks.html is shown, I would like the invoices section's invoicePaid dropdown field to change from "No" to "Yes" using the charge....
herbo's user avatar
  • 13
1 vote
1 answer
144 views

Where to call hook modifyImportRow?

I'm using this Import plugin https://github.com/boboldehampsink/import. It has a hook called modifyImportRow, which would let me process single .csv rows with my custom logic. In this case I have to ...
Alessio Breviglieri's user avatar
1 vote
0 answers
55 views

Make fields sortable in CP

I'm displaying list of fields on frontend (using craft.fields.getFieldsByGroupId) and for that purpose I need the fields in group to be in particular order. Is there a way to add 'order' property to ...
Yuri Salimovskiy's user avatar
1 vote
1 answer
127 views

Can a plugin manually raise another plugin's Event?

I have created an Adjuster which is attached to commerce_lineItems.onPopulateLineItem. The discount criteria is based on validation of a completely separate coupon API, so I created a permission-less ...
casey's user avatar
  • 437
0 votes
1 answer
711 views

How to create custom option/action for backend entry lists

Please excuse me for the title.. I have no idea how to describe my problem better - if someone knows a better description for this question feel free to edit it. I made a screenshot to clarify what I ...
Robin Schambach's user avatar
1 vote
1 answer
70 views

Plugin Development: intercept Entry before returned to template

Is there a hook in Craft to intercept an Entry before being returned to a (front-end) template? Thinking here of ways we can manipulate what is being returned in the Element Criteria Model without ...
Cole Henley's user avatar
  • 1,741
2 votes
1 answer
201 views

How to show details on linked entry in CP (another field inside related entry)

I'm using a row layout SuperTable to create a recipe (ingredients are entries). Is there a way to show another field inside the related entry (not just the title) together with the entry title? I need ...
Jure Srpcic's user avatar
1 vote
1 answer
62 views

How should a multi-stage editorial process be implemented in Craft?

I'm building an editorial system on Craft which has 6-8 editorial stages, such as Assignment, Initial Proofing, Secondary Proofing, etc. It seems that the simplest solution would be to have the ...
Billy Pilgrim's user avatar
2 votes
1 answer
24 views

Close entry editing after set time (for certain a user group)

I have a group of users who are allowed to create entries and edit them but I want to put a window on how much time they have in which they can edit it. For example, after initial submission they ...
Leonard's user avatar
  • 121
2 votes
1 answer
120 views

Insert entry into article field (elementselect?) on a user, with the "onBeforeSaveEntry" hook

I'm having a hard time inserting new content into an elementselect field for a user. Here's the code I'm working on so far, inside a custom plugin init() parent::init(); craft()->on('entries....
Ole's user avatar
  • 245
1 vote
1 answer
222 views

How do I hook into Capture form onPost event?

I am writing a new plugin to hook into a POST event from a bespoke form plugin called "Capture". The Capture plugin fires two different events; the code taken from /craft/plugins/capture/services/...
Alexander Holsgrove's user avatar
2 votes
1 answer
122 views

Plugin add options to entry edition

What I'm trying to do is add two checkbox in the entry edition page, just under the dates or special notes, somewhere here : Then if the checkbox is checked, I check it with an event and perform an ...
ovesco's user avatar
  • 271
2 votes
1 answer
415 views

Where do I put code to use hooks and events from Squarebit's 'Charge' plugin?

I would like to update a specific entry upon the completion of a successful payment through the charge plugin. For this, Charge provides the callback 'charge.onCharge,' as detailed in the 'Hooks & ...
jGaiser's user avatar
  • 35
1 vote
2 answers
639 views

Add custom column to Entry Type index page

I'm creating a plugin and I've been following the Mijingo Craft plugin development videos. I reached the point where a column was added to the entry index page. I was looking to do something similar ...
Pindo's user avatar
  • 203
2 votes
1 answer
401 views

How to use onDeleteEntry?

I currently have a plugin which needs to do things on save and delete entry events. My save entry code is all working perfectly but the onDeleteEntry code doesn't ever fire when I delete an entry. I ...
Mutual's user avatar
  • 442
1 vote
0 answers
66 views

User Group specific asset paths

I've been doing some quite involved work on a site where we want to restrict user access to certain asset paths. Following the post at Assets Folder: Images don't show up I was directed to the ...
Cole Henley's user avatar
  • 1,741
0 votes
1 answer
146 views

Hooking into event when record deleted from custom plugin

We are using a plugin that has created its own record for storing private messages. When deleting a message, it's calling the delete() method on an instance of the record, which appears to be using ...
John O's user avatar
  • 391
1 vote
1 answer
453 views

Displaying an array returned from a hook

I'm writing a plugin which has a hook like: craft()->templates->hook('myHook', function(&$context) { return array('hello', 'there'); }); While I can call it in a template with: {% ...
Phil Gyford's user avatar
4 votes
1 answer
685 views

Incorporating data from an external database into Craft pages

I'm looking at how best to incorporate various sets of data from another MySQL database into a Craft site. Using the Feed Me plugin would be one way, if the data source had feeds, but I'm thinking ...
Phil Gyford's user avatar
5 votes
3 answers
799 views

Template Hook + Caching

A portion of my template is being cached, using the standard cache tag: {% cache %} Within that cached section of the template, I'm using a template hook: {% hook 'myTemplateHook' %} Within that ...
Lindsey D's user avatar
  • 24k
1 vote
1 answer
50 views

Hook calls within a loop always get the Entry, not the loop context?

According to the docs, if I call a hook from within my template: The $context argument will be the current Twig context array, which you’re free to manipulate. So I have a loop in my template ...
Russ Back's user avatar
  • 1,503
1 vote
1 answer
1k views

How can I fire a controller action for a particular route or entry?

So I have an entry that has some content displayed in a template. However ahead of displaying that entry, I want a plugin's action to fire, which pulls some data in from a third party API that will ...
Russ Back's user avatar
  • 1,503
1 vote
1 answer
223 views

Updating index tables' sortable attributes on AJAX

I'm currently writing a plugin enabling users to easily add custom fields to index tables, using the native field layout designer. My current goal is to have any datetime, boolean, string or number ...
Mats Mikkel Rummelhoff's user avatar
3 votes
1 answer
366 views

Element Actions for Entries being viewed from modifyEntrySources

Im using the modifyEntrySources hook in my plugin, when I view the entries based on my custom criteria it doesn't show the checkboxes for element actions, is there a way to get these back or is this a ...
jonleesmith's user avatar
3 votes
2 answers
380 views

How to change the display order of columns in Entry List view?

When adding a custom column to an Entry List view using the modifyEntryTableAttributes hook, how would you also set the display order of columns?
Douglas McDonald's user avatar
3 votes
1 answer
339 views

What does the 'modifyEntrySources' hook do?

What does the modifyEntrySources hook do exactly, and when might one use it? Can someone help clarify this please?
Douglas McDonald's user avatar
1 vote
1 answer
539 views

How to change the display of asset fields in the control panel via plugin?

I would like to modify how assets are displayed within asset fields in the control panel's edit entry page, so that thumbnails are larger and the name is not displayed. After some investigation I ...
Gints Ligotnis's user avatar
2 votes
1 answer
554 views

Pixel & Tonic's Contact Form Plugin - POST submissions to Zapier Webhook URL?

I'm still a beginner with PHP so please bear with me. I've installed the Contact Form plugin for Craft by Pixel and Tonic, and have it configured to work as expected. However, I'd like to have the ...
Chris OBrien's user avatar
2 votes
1 answer
1k views

Hook in before template gets rendered

The only thing I don't really like about Craft is that I have to fetch and eventually manipulate my entry in the twig template itself. Is there a way to hook into the current request before the ...
Sidney Widmer's user avatar
4 votes
1 answer
395 views

Hook into rendered templates?

I am hoping to write a plug-in to cache pages as static HTML. Is there a hook that would give me access to the full rendered HTML of a page?
Matt Fordham's user avatar
2 votes
0 answers
53 views

Hook for Image Transforms [duplicate]

I'm interested in creating a plug-in that creates a new type of transform. Is there a hook/event related to image transforms?
Brett DeWoody's user avatar
8 votes
1 answer
1k views

How do I handle named route variables passed to a controller?

I'm writing a plugin that uses the registerSiteRoutes hook to create some new routes, and passes those routes to some controllers. In these routes, I have a few pieces of the URL that I'm capturing as ...
shanecavaliere's user avatar