Using plugin to replace code in specific pages
Moderators: Developer, Contributor
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Using plugin to replace code in specific pages
I'm wanting to know how I would replace code in the signup_page.php with my own form code. I'm also wanting to know how I can find the </head> tag and replace it with my code followed by the </head> tag.
Re: Using plugin to replace code in specific pages
Plugins are event based, you can find those back in core/events_inc.php
You have various events available for the lay-out etcetra.
In addition you can add events yourself ( although this requires an adjustment of the core code).
You have various events available for the lay-out etcetra.
In addition you can add events yourself ( although this requires an adjustment of the core code).
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: Using plugin to replace code in specific pages
The problem with events is they aren't where I need. Such as EVENT_LAYOUT_RESOURCES, it loads my code before everything else and I need mine to be right before </head>.
Re: Using plugin to replace code in specific pages
So you define your own event ( declare it within the plugin) and add the event statement @ the place where you require it.
If it needs to be right before the </head> statement, you need to declare your event within function html_head_end which you can find within core/html_api.php
If it needs to be right before the </head> statement, you need to declare your event within function html_head_end which you can find within core/html_api.php
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: Using plugin to replace code in specific pages
Since I'm new to coding a plugin for MantisBT. How do I declare it in my plugin and how do I add the event statement where I need it?cas wrote: ↑27 Aug 2020, 16:41 So you define your own event ( declare it within the plugin) and add the event statement @ the place where you require it.
If it needs to be right before the </head> statement, you need to declare your event within function html_head_end which you can find within core/html_api.php
Re: Using plugin to replace code in specific pages
you can find that in the developer guide which is included in your installation.
Clearly you need to insert the event command @ the location where you would need to execute the code you want
Clearly you need to insert the event command @ the location where you would need to execute the code you want
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: Using plugin to replace code in specific pages
I know how to trigger events but I wasn't sure about adding my own event to the core file because if I do that then it will get replaced on updates to Mantis so it would need to be done via a file similar to what we do with config_inc.php is that possible with adding my own event to html_api.php or is there a way to call the html_head_end function in my plugin to add code? If so, how? I'm a visual learn so sample code would help in the long run.
Re: Using plugin to replace code in specific pages
you can try to declare the events in config_inc.php but you would still need to adjust the core file to insert it @ the right place. I am not aware of a plugin that allows you to dynamically change code.
In case you believe such an event to be essential, you can request to have it added in the next release ( following the procedure to get this done, available on the mantis website).
In case you believe such an event to be essential, you can request to have it added in the next release ( following the procedure to get this done, available on the mantis website).
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: Using plugin to replace code in specific pages
After some testing I found I don't need a new point added but being able to replace the captcha that exists now with custom code would be needed without editing core files.