This document contains details about event handlers (also known as Hooks) provided by Semantic MediaWiki to enable users to extent and integrate custom specific solutions.
Available hooks
Implementing a hook should be made in consideration of the expected performance impact for the front-end (additional DB read/write transactions etc.) and/or the back-end (prolonged job backlog etc.) process.
Setup and registry
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.datatype.inittypes.md "`SMW::DataType::initTypes`" to add additional https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/architecture/datamodel.datatype.md "DataType" support
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.property.initproperties.md "`SMW::Property::initProperties`" to add additional predefined properties
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.constraint.initconstraints.md "`SMW::Constraint::initConstraints`" to add custom constraints
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.getpreferences.md "`SMW::GetPreferences`" to add extra preferences that are ordered on the Semantic MediaWiki user preference tab
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.setup.afterinitializationcomplete.md "`SMW::Setup::AfterInitializationComplete`" to modify global configuration after initialization of Semantic MediaWiki is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.settings.beforeinitializationcomplete.md "`SMW::Settings::BeforeInitializationComplete`" to modify the Semantic MediaWiki configuration before the initialization is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.grouppermissions.beforeinitializationcomplete.md "`SMW::GroupPermissions::BeforeInitializationComplete`" to modify the Semantic MediaWiki permissions before the initialization is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.event.registereventlisteners.md "`SMW::Event::RegisterEventListeners`" to register additional event listeners
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.listener.registerpropertychangelisteners.md "`SMW::Listener::ChangeListener::RegisterPropertyChangeListeners`" allows to register and listen to individual property changes
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.schema.registerschematypes.md "`SMW::Schema::RegisterSchemaTypes`" allows to register additional schema types
Store
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.beforedeletesubjectcomplete.md "`SMW::SQLStore::BeforeDeleteSubjectComplete`" is called before the deletion of a subject is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.afterdeletesubjectcomplete.md "`SMW::SQLStore::AfterDeleteSubjectComplete`" is called after the deletion of a subject is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.beforechangetitlecomplete.md "`SMW::SQLStore::BeforeChangeTitleComplete`" is called before change to a subject is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.beforedatarebuildjobinserts.md "`SMW::SQLStore::BeforeDataRebuildJobInserts`" to add update jobs while running the rebuild process
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.beforedataupdatecomplete.md "`SMW::SQLStore::BeforeDataUpdateComplete`" to extend the
SemanticData
object before the update is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.afterdataupdatecomplete.md "`SMW::SQLStore::AfterDataUpdateComplete`" to process information after an update has been completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.store.beforedataupdatecomplete.md "`SMW::Store::BeforeDataUpdateComplete`" to extend the
SemanticData
object before the update is completed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.store.afterdataupdatecomplete.md "`SMW::Store::AfterDataUpdateComplete`" to process information after an update has been completed
Property tables
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.addcustomfixedpropertytables.md "`SMW::SQLStore::AddCustomFixedPropertyTables`" to add fixed property table definitions
SMW::SQLStore::updatePropertyTableDefinitions
to add additional table definitions during initialization
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.entityreferencecleanupcomplete.md "`SMW::SQLStore::EntityReferenceCleanUpComplete`" to process information about an entity where the clean-up has been finalized
Installer
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.installer.beforecreatetablescomplete.md "`SMW::SQLStore::Installer::BeforeCreateTablesComplete`" to add additional table indices
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.installer.aftercreatetablescomplete.md "`SMW::SQLStore::Installer::AfterCreateTablesComplete`" to add extra tables after the creation process as been finalized
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.sqlstore.installer.afterdroptablescomplete.md "`SMW::SQLStore::Installer::AfterDropTablesComplete`" to remove extra tables after the drop process as been finalized
Query
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.store.beforequeryresultlookupcomplete.md "`SMW::Store::BeforeQueryResultLookupComplete`" to return a
QueryResult
object before the standard selection process is started and allows to suppress the standard selection process completely by returning false
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.store.afterqueryresultlookupcomplete.md "`SMW::Store::AfterQueryResultLookupComplete`" to manipulate a
QueryResult
after the selection process
Parser, annotations, and revision
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.parser.beforemagicwordsfinder.md "`SMW::Parser::BeforeMagicWordsFinder`" to extend the magic words list that the
InTextAnnotationParser
should inspect on a given text section
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.parser.afterlinksprocessingcomplete.md "`SMW::Parser::AfterLinksProcessingComplete`" to add additional annotation parsing after
InTextAnnotationParser
has finished the processing of standard annotation links (e.g. [[...::...]]
)
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.parser.parseraftertidypropertyannotationcomplete.md "`SMW::Parser::ParserAfterTidyPropertyAnnotationComplete`" allows to add additional
PropertyAnnotator
as part of the ParserAfterTidy
after default annotators have been executed
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.fileupload.beforeupdate.md "`SMW::FileUpload::BeforeUpdate`" to add extra annotations on a
FileUpload
event before the Store
update is triggered
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.revisionguard.changerevision.md "`SMW::RevisionGuard::ChangeRevision`" to forcibly change a revision used during content parsing
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.revisionguard.changerevisionid.md "`SMW::RevisionGuard::ChangeRevisionID`" to forcibly change the revision ID as in case of the
Factbox
when building the content.
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.revisionguard.isapprovedrevision.md "`SMW::RevisionGuard::IsApprovedRevision`" to define whether a revision is approved or needs to be suppressed.
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.revisionguard.changefile.md "`SMW::RevisionGuard::ChangeFile`" to forcibly change the file version used
Miscellaneous
SMW::Factbox::BeforeContentGeneration
to replace or amend text elements shown in a Factbox
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.browse.afterincomingpropertieslookupcomplete.md "`SMW::Browse::AfterIncomingPropertiesLookupComplete`" to extend the incoming properties display for
Special:Browse
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.browse.beforeincomingpropertyvaluesfurtherlinkcreate.md "`SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate`" to replace the standard
SearchByProperty
with a custom link in Special:Browse
to an extended list of results (return false
to replace the link)
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.browse.afterdatalookupcomplete.md "`SMW::Browse::AfterDataLookupComplete`" to extend the HTML with data displayed on
Special:Browse
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.admin.registertaskhandlers.md "`SMW::Admin::RegisterTaskHandlers`" to extend available
TaskHandler
used in the Special:SemanticMediaWiki
dashboard
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.resultformat.overridedefaultformat.md "`SMW::ResultFormat::OverrideDefaultFormat`" to override the default result format handling
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.job.afterupdatedispatcherjobcomplete.md "`SMW::Job::AfterUpdateDispatcherJobComplete`" to add additional update jobs for a property and related subjects
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.exporter.controller.addexpdata.md "`SMW::Exporter::Controller::AddExpData`" to add additional RDF data for a selected subject
- https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.maintenance.afterupdateentitycollationcomplete.md "`SMW::Maintenance::AfterUpdateEntityCollationComplete`" runs after the
updateEntityCollection.php
script has finished processing the update of entity collation changes
Deprecated hooks
smwInitDatatypes
(since 1.9)
smwInitProperties
(since 2.1)
smwShowFactbox
(since 2.1)
smwRefreshDataJobs
(since 2.3)
smwUpdatePropertySubjects
(since 1.9)
smwAddToRDFExport
(since 3.0)
SMWSQLStore3::updateDataBefore
(since 3.1)
SMWSQLStore3::updateDataAfter
(since 2.3)
SMWStore::updateDataBefore
(since 3.1)
SMWStore::updateDataAfter
(since 3.1)
SMWResultFormat
(since 3.1)