Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
GriefCode Posted August 18, 2015 Posted August 18, 2015 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
newbie LAC Posted August 18, 2015 Posted August 18, 2015 Hello,\IPS\cms\Records::containerFollowerCount( $database )Why $database? $database is object of IPS\cms\Databases. Param must be object of IPS\cms\Categories%cat_id%
GriefCode Posted August 18, 2015 Author Posted August 18, 2015 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)
newbie LAC Posted August 18, 2015 Posted August 18, 2015 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 != $databaseYou need create object. Something like this{{$catClass = '\IPS\cms\Categories' . $database->_id;}} {{$category = $catClass::load( $database->_id );}}
GriefCode Posted August 18, 2015 Author Posted August 18, 2015 {template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $category )"}$category != $databaseYou 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 :-)
newbie LAC Posted August 18, 2015 Posted August 18, 2015 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,
GriefCode Posted August 18, 2015 Author Posted August 18, 2015 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.
Marcher Technologies Posted August 18, 2015 Posted August 18, 2015 {template="follow" app="core" group="global" params="'cms','categories' . $category->database_id, $category->_id, \IPS\cms\Records::containerFollowerCount( $category )"}$category != $databaseYou 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.