Kyle F Posted February 9, 2020 Posted February 9, 2020 Hi all. For Pages, what code would I need to grab the member count for a block plugin?
Daniel F Posted February 9, 2020 Posted February 9, 2020 {{$count=\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['completed=?', true] )->first();}} Total Members: {$count} Kyle F 1
Kyle F Posted February 9, 2020 Author Posted February 9, 2020 2 hours ago, Daniel F said: {{$count=\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['completed=?', true] )->first();}} Total Members: {$count} I get an error when doing this: ParseError: syntax error, unexpected '}' (0) #0 /home/unified1/public_html/system/Helpers/Form/FormAbstract.php(377): IPS\cms\Blocks\_Block->IPS\cms\Blocks\{closure}('{{$count=\\IPS\\D...') #1 /home/unified1/public_html/system/Helpers/Form/TextArea.php(119): IPS\Helpers\Form\_FormAbstract->validate() #2 /home/unified1/public_html/system/Helpers/Form/FormAbstract.php(165): IPS\Helpers\Form\_TextArea->validate() #3 /home/unified1/public_html/system/Helpers/Form/FormAbstract.php(142): IPS\Helpers\Form\_FormAbstract->setValue(true) #4 /home/unified1/public_html/system/Helpers/Form/TextArea.php(66): IPS\Helpers\Form\_FormAbstract->__construct('block_content', '', false, Array, Object(Closure), NULL, NULL, 'block_content') #5 /home/unified1/public_html/system/Helpers/Form/Codemirror.php(68): IPS\Helpers\Form\_TextArea->__construct('block_content', '', false, Array, Object(Closure), NULL, NULL, 'block_content') #6 /home/unified1/public_html/applications/cms/sources/Blocks/Block.php(668): IPS\Helpers\Form\_Codemirror->__construct('block_content', '', false, Array, Object(Closure), NULL, NULL, 'block_content') #7 /home/unified1/public_html/system/Node/Controller.php(489): IPS\cms\Blocks\_Block->form(Object(IPS\Helpers\Form)) #8 /home/unified1/public_html/init.php(820) : eval()'d code(16): IPS\Node\_Controller->_addEditForm(Object(IPS\cms\Blocks\Block)) #9 /home/unified1/public_html/system/Node/Controller.php(388): IPS\Node\rules_hook_ipsNodeController->_addEditForm(Object(IPS\cms\Blocks\Block)) #10 /home/unified1/public_html/system/Dispatcher/Controller.php(85): IPS\Node\_Controller->form() #11 /home/unified1/public_html/system/Node/Controller.php(62): IPS\Dispatcher\_Controller->execute() #12 /home/unified1/public_html/applications/cms/modules/admin/pages/blocks.php(39): IPS\Node\_Controller->execute() #13 /home/unified1/public_html/system/Dispatcher/Dispatcher.php(152): IPS\cms\modules\admin\pages\_blocks->execute() #14 /home/unified1/public_html/admin/index.php(14): IPS\_Dispatcher->run() #15 {main} Code: {{$count=\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['completed=?', true] )->first();}} {$count}
Kyle F Posted March 13, 2020 Author Posted March 13, 2020 Could I still get some help with this issue?
Morrigan Posted March 23, 2020 Posted March 23, 2020 @Kyle F Use this: Total Members: {expression="\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['completed=?', true] )->first()"} Maxxius and Kyle F 2
Kyle F Posted March 27, 2020 Author Posted March 27, 2020 On 3/23/2020 at 8:34 AM, Morrigan said: @Kyle F Use this: Total Members: {expression="\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['completed=?', true] )->first()"} Thanks, Morrigan! That worked. Sorry for the late response here; PC power supply became defective and had to go through a 3 week wait for a replacement from Corsair. Finally got my PC back! 🙂
Kyle F Posted March 31, 2020 Author Posted March 31, 2020 On 3/27/2020 at 11:24 PM, Morrigan said: No worries. Enjoy. Hey, Morrigan, what would the line of code be to grab the number of users from a specific member group? Lets say... the "banned" group with ID 15.
Morrigan Posted March 31, 2020 Posted March 31, 2020 @Kyle F {expression="\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['member_group_id=?', ##])->first()"} I think. Kyle F 1
Kyle F Posted March 31, 2020 Author Posted March 31, 2020 24 minutes ago, Morrigan said: @Kyle F {expression="\IPS\Db::i()->select( 'COUNT(*)', 'core_members', ['member_group_id=?', ##])->first()"} I think. Oof. When using that above I get this: Quote Something went wrong. Check the values provided on the marked tabs and try again.
Adriano Faria Posted March 31, 2020 Posted March 31, 2020 2 minutes ago, Kyle F said: Oof. When using that above I get this: Did you replace the ## by your group ID?
Kyle F Posted March 31, 2020 Author Posted March 31, 2020 Oh shoot, I thought it was the question mark I had to replace. 😅 Morrigan 1
Recommended Posts