News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Why won't my code grab a list of cats and types?

Started by Jade Elizabeth, December 15, 2014, 10:17:23 AM

Previous topic - Next topic

Jade Elizabeth

I dunno what's going on but when I try to do $context['work_categories'] in the template it says "Resource id #31" :(. I'm developing on 2.1.


WorkIndex.php
http://pastebin.com/zAhhAr3P

Subs-WorkIndex.php
http://pastebin.com/G0wC0QR6

All I want is a list of categories and types similar to how the boards section does it in admin with boards and cats, but I'm having trouble understanding how the hell SMF does anything at the moment so I thought I would start by mimicking the BoardIndex files. Someone please help I am so lost :(.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

vbgamer45

$work_categories is the issue you are only assigning it for the resource for mysql all the other work you are doing in your function isn't touching $work_categories

$work_categories = $result_work_types;

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Jade Elizabeth

That's on line 35 of the second file. Is it in the wrong spot or something?
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

vbgamer45

You have three sets of data not sure which one you are trying to return

$categories, $parent_map and $types   at the end.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Jade Elizabeth

I tried printing $type and $categories and they are undefined.

I want a list of all the categories and their types (they're the equivalent of categories and boards/childboards). I thought that was what all that code was doing? So I want $categories to work.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

vbgamer45

Try changing
return $work_categories;
To
return $categories;
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Jade Elizabeth

OMG yay it worked! But it's literally only showing the categories. How do I get it to show the categories and the types?

Also how come it worked as $categories? I changed it to work_categories cause I thought it might conflict with SMF's categories.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Jade Elizabeth

I think it's not populating the [types] part?

Array
(
    [1] => Array
        (
            [id] => 1
            [name] => Creative Writing
            [description] => creative writing desc
            [href] => http://localhost/CreativeBurrow/index.php#c1
            [types] => Array
                (
                )

            [link] => Creative Writing
        )


That one should have 6 types and 5 child types.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Jade Elizabeth

Hold that thought I am going to approach this from a new direction :).

Thanks so much for replying VB!! You really helped me a lot!! :D <3
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: