Jump to content

How to create hooks in invision new version?


Go to solution Solved by teraßyte,

Recommended Posts

Posted
On 10/17/2023 at 11:41 AM, DawPi said:

You have given the general link. Any specific link to convert the hooks in previous i.e. 3.6 version to new 4.7 version will help me a lot.

 

Right now which I understand is that, I need to enable developer mode, then I can start creating plugins. But i m still not sure about what's next steps? Right now trying to setup developer mode at local.

Posted
Just now, Marc Stridgen said:

There is no specific link on how to convert from 3.4 to 4.7 hooks, no. Its an entirely different platform, so it wouldnt be so much 'conversion' as rewriting them entirely

So, if I had to perform an action when user creates a new Post, then can you suggest the process to be followed in new version?

Posted

Im not a developer on the platform myself, but I would suggest going through the documentation that has been linked to above, as developing for 4 is very different to version 3. This is likely what you would need to do what you are looking to do there, but with going through all of it, you are going to hit things that make no sense until you do.

 

Posted

- New topic: hook on \IPS\forums\Topic:

	public static function createFromForm( $values, \IPS\Node\Model $container = NULL, $sendNotification = TRUE )
	{
		$item = parent::createFromForm( $values, $container, $sendNotification );

		//do your stuff

		return $item;
	}

- New post: hook on \IPS\forums\Topic\Post:

	public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL, $anonymous=NULL )
	{
		$reply = parent::create( $item, $comment, $first, $guestName, $incrementPostCount, $member, $time, $ipAddress, $hiddenStatus, $anonymous );

		//do your stuff

		return $reply;
	}

 

Posted
14 minutes ago, Adriano Faria said:

- New topic: hook on \IPS\forums\Topic:

	public static function createFromForm( $values, \IPS\Node\Model $container = NULL, $sendNotification = TRUE )
	{
		$item = parent::createFromForm( $values, $container, $sendNotification );

		//do your stuff

		return $item;
	}

- New post: hook on \IPS\forums\Topic\Post:

	public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL, $ipAddress=NULL, $hiddenStatus=NULL, $anonymous=NULL )
	{
		$reply = parent::create( $item, $comment, $first, $guestName, $incrementPostCount, $member, $time, $ipAddress, $hiddenStatus, $anonymous );

		//do your stuff

		return $reply;
	}

 

Hey Adriano,

I have to write the above code in which file? As per the guide i m setting up developer mode at local.

Do i need  developer mode at local to write above code? Or there is any other way to do this?

Posted

After doing the steps given the articles and suggested by you. When i run the folder at my local, i am getting below error. I checked in the specified location but could not found the file specified. Can someone guide please?

 

file_get_contents(D:\wamp64\www\marketing_version4.7/applications/forums/data/versions.json): Failed to open stream: No such file or directory

Posted
On 10/19/2023 at 5:13 PM, Adriano Faria said:

1: You need to have a local install of the board (with Apache PHP/MySQL, or a Wampserver, etc.).

2: upload the dev tools:

3: Enable the developer mode:

4: create a plugin with 2 code hooks in the classes I pointed above.

 

Hello adriano,

I am able to complete step 1,2,3 specified. But as you mentioned I have to write the code in which file among the below plugins\hooks.php file

  '\\IPS\\forums\\Forum' =>
  array (
    2 =>
    array (
      'file' => 'applications/cms/hooks/Forum.php',
      'class' => 'cms_hook_Forum',
    ),
  ),
  '\\IPS\\forums\\modules\\admin\\forums\\forums' =>
  array (
    3 =>
    array (
      'file' => 'applications/cms/hooks/forums.php',
      'class' => 'cms_hook_forums',
    ),
  ),
 
Posted
On 10/23/2023 at 7:23 PM, Adriano Faria said:

Create an application or a plugin. Go to dev center, tab Hooks and create a hook then you’ll have a file in applications/appkeyfolder/hooks or plugins/pluginkeyfolder/hooks. Add the script in this file.

I am able to access the hooks menu now. 

I am able to add the hook on process form. But here the issue is I have to update the values in the table which is not the part of invision table. 

For e.g i have table table1. I am using mysqli to update the values on the basis of userid. As this is the common column between ipcore_members and table1.

I am using one dbconnect.php file to connect to the db using mysqli driver.

But the $connection object is not available to me in the hook file.

Can you please help?

Posted
20 hours ago, teraßyte said:

You can use the DB class to run queries, there is no need to use a separate dbconnect.php file:

 

By default its taking ip in the table name. Earlier in the version 3.6 we have used the table name without the tbl_prefix. So, Can you help me how to use the how to fetch the data directly from the table without using tbl_prefix?

Posted
55 minutes ago, Jyoti Rani said:

By default its taking ip in the table name. Earlier in the version 3.6 we have used the table name without the tbl_prefix. So, Can you help me how to use the how to fetch the data directly from the table without using tbl_prefix?

Search for external on

 

Posted (edited)
23 minutes ago, Adriano Faria said:

Search for external on

 

Found the solution as you mentioned at the same place Adriano. Thanks for the reply!

Edited by Jyoti Rani
Posted
20 minutes ago, Jyoti Rani said:

Found the solution as you mentioned at the same place Adriano. Thanks for the reply!

Now another query is, there is xml file which gets generated in the end.

But how to create it?

How to upload it to sever from developer's mode at local?

Posted
3 minutes ago, Jyoti Rani said:

But how to create it?

Could contain: Text, Page

 

3 minutes ago, Jyoti Rani said:

How to upload it to sever from developer's mode at local?

Not sure I follolw your question. Do you want to upload your own hook to the dev install?

Make sure you make a copy and keep the dev folder of your app/plugin. You will need to work in your app/plugin in the future.

Posted
7 minutes ago, Adriano Faria said:

Could contain: Text, Page

 

Not sure I follolw your question. Do you want to upload your own hook to the dev install?

Make sure you make a copy and keep the dev folder of your app/plugin. You will need to work in your app/plugin in the future.

 

10 minutes ago, Adriano Faria said:

Could contain: Text, Page

 

Not sure I follolw your question. Do you want to upload your own hook to the dev install?

Make sure you make a copy and keep the dev folder of your app/plugin. You will need to work in your app/plugin in the future.

But i m not getting this dropdown in my screen.

Please see below

 

Could contain: Page, Text

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...