SimplePortal

Customization => Blocks and Modifications => Topic started by: Kryzen on August 09, 2011, 10:38:46 AM

Title: Category Listing v1.0
Post by: Kryzen on August 09, 2011, 10:38:46 AM
Category Listing
v1.0.1

Category Listing is a very simple block. This will show a block with all categories and will link to them. If no categories are available, it will say that. I hope you enjoy it. :)

Installing is very simple. Just create a new PHP code block and use this code:
Code: [Select]
/**
Category Listing modification by Dr. Deejay
Module created for SimplePortal
Version 1.0.1
*/

global $smcFunc, $settings;

// Meh, we need a list!
echo '<ul class="sp_list">';

// Retrieve the categories form the database
$result = $smcFunc['db_query']('', 'SELECT *
    FROM {db_prefix}categories
ORDER BY cat_order ASC', array());

// If we don't have anything do show, just say we haven't
if($smcFunc['db_num_rows']($result) == 0)
echo '
<li>No categories found</li>';

// Show them!
while($category = $smcFunc['db_fetch_assoc']($result))
{
// A simple echo...
echo '
<li>' . sp_embed_image('dot') . ' <a href="#c'.$category['id_cat'].'" class="smalltext">'.$category['name'].'</a></li>';
}

echo '</ul>';

Enjoy!
Dr. Deejay
Title: Re: Category Listing v1.0
Post by: Kryzen on March 31, 2012, 04:40:11 AM
Ok I know that I've promised to work on something else, but I've released 1.0.1 that uses sp_embed_image instead of html.
Title: Re: Category Listing v1.0
Post by: iobit on February 08, 2013, 03:27:38 PM
Thanks for this mod, but i have this error when try to applt modify: Database error in block code. Please check the code.
Title: Re: Category Listing v1.0
Post by: iobit on February 08, 2013, 04:21:25 PM
Ok i solved with this: http://simpleportal.net/index.php?topic=12146.msg61116#msg61116

but now i have another problem when click on category, nothing happens
Title: Re: Category Listing v1.0
Post by: Kryzen on February 09, 2013, 07:53:54 AM
Glad to hear you solved your problem. :)

but now i have another problem when click on category, nothing happens
It only works on the boardindex (where the categories and boards are).

The code is really simple, though. It assumes all categories are public. I should rewrite this some day lol.
Title: Re: Category Listing v1.0
Post by: player.samp on April 08, 2014, 12:23:05 PM
I have an error with the database when I try to put a block like this. :(
Title: Re: Category Listing v1.0
Post by: AngelinaBelle on April 08, 2014, 12:27:57 PM
Do you get any error when you preview the block?
What error do you get when you try to save the block?
Title: Re: Category Listing v1.0
Post by: player.samp on April 08, 2014, 12:29:36 PM
I haven't tried to Preview the block... I just try to add the block and I get an error:

"Database error in block code. Please check the code."
Title: Re: Category Listing v1.0
Post by: AngelinaBelle on April 08, 2014, 12:43:20 PM
Please try "preview block".  If "preview block"  succeeds, but you still cannot save the block, then you may need to go to Simple Portal Configuration > General > Disable PHP Validation and check that box.
Title: Re: Category Listing v1.0
Post by: player.samp on April 08, 2014, 03:04:31 PM
There is no error, but when I do preview, what I see on the block is just the title, but the content itself - there is nothing...
Title: Re: Category Listing v1.0
Post by: AngelinaBelle on April 08, 2014, 03:44:44 PM
Can you check the HTML actually produced?
To do this, it would be easiest to display the block on some page of your forum and save the block.
Then go look at that page.

Either there will be some kind of error message, or there will be, at a minimum,
Code: [Select]
<ul class="sp_list">
</ul>
within that block (though of course sp_list could appear in other simpleportal blocks as well).

I cannot imagine that
$result = $smcFunc['db_query']('', 'SELECT *
                            FROM {db_prefix}categories
                           ORDER BY cat_order ASC', array());

is going to give you some kind of database error, but I could be  wrong.
Title: Re: Category Listing v1.0
Post by: USFA on April 11, 2014, 10:07:11 PM
I see the mod works, but how do you modify the contents ?
It showed links but they went no where.

Think I am not using it correctly.

Help please.
Title: Re: Category Listing v1.0
Post by: AngelinaBelle on April 14, 2014, 09:31:59 AM
USFA -- this block should list all categories in your forum.
If you have no categories found, it should say that there are no categories.
Title: Re: Category Listing v1.0
Post by: USFA on April 15, 2014, 07:37:16 PM
Hmm it does not say anything.
Title: Re: Category Listing v1.0
Post by: AngelinaBelle on April 16, 2014, 06:50:28 AM
That seems odd.

Where your block code says
Code: [Select]
if($smcFunc['db_num_rows']($result) == 0)Please try
Code: [Select]
echo '<p>number of rows: ' , $smcFunc['db_num_rows']($result), '</p>';
if($smcFunc['db_num_rows']($result) == 0)
and see what kind of output you get.
Title: Re: Category Listing v1.0
Post by: br360 on December 27, 2015, 07:00:20 PM
This is is pretty cool block but I noticed that there is no way to hide certain categories from being listed. I have categories on the forum with hidden boards, all the boards are hidden in that category, yet the hidden category is still listed in this block's category list.

Is there any way to hide those categories from showing in this block?
Title: Re: Category Listing v1.0
Post by: owenenene on January 13, 2017, 02:36:51 PM
This is is pretty cool block but I noticed that there is no way to hide certain categories from being listed. I have categories on the forum with hidden boards, all the boards are hidden in that category, yet the hidden category is still listed in this block's category list.

Is there any way to hide those categories from showing in this block?

This. Is there anyway we can hide certain categories from being shown?
Title: Re: Category Listing v1.0
Post by: ccbtimewiz on January 13, 2017, 11:14:18 PM
As far as I am aware, only those who can access those boards can see them listed on the block
SimplePortal 2.3.8 © 2008-2024, SimplePortal