Jump to content
This topic contains 35 posts. A summary containing the most significant posts is available

Featured Replies

Posted

Hi

In the invision version 3.6 i have 2 hooks. During the upgrade these has been lost. 

Now in the version invision 4.7, How to implement the hooks?

Any guide or link helps me a lot.

 

Solved by teraßyte

Go to solution
  • Author
 

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.

  • Community Expert

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

  • Author
 

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?

  • Community Expert

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.

 

 

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?

New post or new topic?

  • Author
 

New post or new topic?

New Post as well as New Topic.

- 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;
	}

 

  • Author
 

- 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?

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.

 

  • Author

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

  • Author
 

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',
    ),
  ),
 

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.

  • Author
 

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?

  • Community Expert

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

 

  • Author
 

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?

 

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

 

  • Author
 

Search for external on

 

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

Edited by Jyoti Rani

  • Author
 

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?

 

But how to create it?

Could contain: Text, Page

 

 

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.

  • Author
 

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.

 

 

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

  • Author
 

Enable IN_DEV mode. It will appear.

Yes. Thanks again for your prompt reply!

Recently Browsing 0

  • No registered users viewing this page.