Questions tagged [hook]
The hook tag has no usage guidance.
44
questions
1
vote
1
answer
58
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.
...
1
vote
1
answer
247
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 ...
0
votes
1
answer
105
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:
<...
0
votes
1
answer
73
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(...
2
votes
1
answer
177
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 ...
1
vote
1
answer
67
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?
2
votes
1
answer
247
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 ...
1
vote
1
answer
62
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',...
1
vote
0
answers
27
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:
...
1
vote
1
answer
510
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 ...
1
vote
1
answer
150
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 ...
1
vote
1
answer
691
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:
$...
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....
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 ...
1
vote
0
answers
53
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 ...
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 ...
0
votes
1
answer
691
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 ...
1
vote
1
answer
69
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 ...
2
votes
1
answer
192
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 ...
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 ...
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 ...
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....
1
vote
1
answer
218
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/...
2
votes
1
answer
121
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 ...
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 & ...
1
vote
2
answers
625
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 ...
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 ...
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 ...
0
votes
1
answer
141
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 ...
1
vote
1
answer
451
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:
{% ...
4
votes
1
answer
678
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 ...
5
votes
3
answers
789
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 ...
1
vote
1
answer
48
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 ...
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 ...
1
vote
1
answer
220
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 ...
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 ...
3
votes
2
answers
379
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?
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?
1
vote
1
answer
527
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 ...
2
votes
1
answer
549
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 ...
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 ...
4
votes
1
answer
393
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?
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?
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 ...