Jump to content

Followercount seems not to work


GriefCode

Recommended Posts

Posted

Hey,

i just created a template for the reasles notes, but i notice that the followercount is not working correctly, this is the way i included the follower:

{template="follow" app="core" group="global" params="'cms','categories' . $database->_id, $database->_id, \IPS\cms\Records::containerFollowerCount( $database )"}

It does show me actually that im following the content, and additional when i click the number im getting a pop up with the followers.
I couldn't find a documentation regarding templates like this. What did i wrong in that case, and what should have been the right way?

Regards

Posted

Thanks for your reply, the issue is that i dont have any categories, normally.

Since it doesnt through any error, it should also work like this.
I copied this code from Listing.

However, im in "Category Articles", there is probably no instance of IPS\cms\Categories%cat_id% (if im not wrong)

Posted

I copied this code from Listing.

			{template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $category )"}

$category != $database

You need create object. Something like this

{{$catClass = '\IPS\cms\Categories' . $database->_id;}}
{{$category	= $catClass::load( $database->_id );}}

 

Posted
			{template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $category )"}

$category != $database

You need create object. Something like this

{{$catClass = '\IPS\cms\Categories' . $database->_id;}}
{{$category	= $catClass::load( $database->_id );}}

 

Thanks, works now as it should. Still wondering why its not checked against typehints, but well :-)

Posted

Still wondering why its not checked against typehints, but well :-)

You are wrong :)

\system\Content\Item.php

	/**
	 * Container Follower Count
	 *
	 * @param	\IPS\Node\Model	$container		The container
	 * @return	int
	 */
	public static function containerFollowerCount( \IPS\Node\Model $container )

\applications\cms\sources\Databases\Databases.php

class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions

\applications\cms\sources\Categories\Categories.php

class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions

Databases and Categories extend \IPS\Node\Model

Try use 

			{template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $fake )"}

you get an error 

4096: Argument 1 passed to IPS\Content\_Item::containerFollowerCount() must be an instance of IPS\Node\Model, null given,

Posted
 

You are wrong :)

\system\Content\Item.php

	/**
	 * Container Follower Count
	 *
	 * @param	\IPS\Node\Model	$container		The container
	 * @return	int
	 */
	public static function containerFollowerCount( \IPS\Node\Model $container )

\applications\cms\sources\Databases\Databases.php

class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions

\applications\cms\sources\Categories\Categories.php

class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions

Databases and Categories extend \IPS\Node\Model

Try use 

			{template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $fake )"}

you get an error 

Ah okay, now i understand this.

Thanks for the continues information. I apperciate your work and support.

Posted
			{template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $category )"}

$category != $database

You need create object. Something like this

{{$catClass = '\IPS\cms\Categories' . $database->_id;}}
{{$category	= $catClass::load( $database->_id );}}

 

You... do realize that code only 'works' by chance, but is still wrong? You are loading the category in database x with an id of x, not the currently viewed category, or even a guarantee a category is in that database with said matching id? With a database 'id' of say, 16, it would attempt to load a category with 'id' of 16, which may or may not exist.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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