2.next and categories functions

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

2.next and categories functions

Stefano-10
O italian forum we are cotinously questions about how to have a
wp_list_cats show only some categories, but not using exclude but how
to include the desired categories.

If you have 30 cats and you wanna have a page that show some cats (2
or 3) another page with soem other cats etc using the exclude
parameters is not so usefull particualry if the categorises changes
and some new were added ina  second time.

Havng a include option for this tag would be nice, wouldn't be ?

--

Stefano Aglietti - StallonIt on IRCnet - ICQ#: 2078431
Email: [hidden email] [hidden email]
Sites: http://www.40annibuttati.it (personal blog)
       http://www.wordpress-it.it (WordPress Italia)
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

Ryan Boren
Stefano wrote:

> O italian forum we are cotinously questions about how to have a
> wp_list_cats show only some categories, but not using exclude but how
> to include the desired categories.
>
> If you have 30 cats and you wanna have a page that show some cats (2
> or 3) another page with soem other cats etc using the exclude
> parameters is not so usefull particualry if the categorises changes
> and some new were added ina  second time.
>
> Havng a include option for this tag would be nice, wouldn't be ?

I'll add an "include" or "only" option.

Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

Stefano-10
Il Thu, 02 Mar 2006 15:18:32 -0800, Ryan Boren <[hidden email]> scrive:

>> Havng a include option for this tag would be nice, wouldn't be ?
>
>I'll add an "include" or "only" option.

Thanks it will be really apreciate :)

--

Stefano Aglietti - StallonIt on IRCnet - ICQ#: 2078431
Email: [hidden email] [hidden email]
Sites: http://www.40annibuttati.it (personal blog)
       http://www.wordpress-it.it (WordPress Italia)
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

David House
In reply to this post by Ryan Boren
On 02/03/06, Ryan Boren <[hidden email]> wrote:
> I'll add an "include" or "only" option.

Don't forget to commit http://trac.wordpress.org/ticket/2328 or
something similar ;)

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

Stefano-10
Il Fri, 3 Mar 2006 11:37:38 +0000, "David House" <[hidden email]>
scrive:

>On 02/03/06, Ryan Boren <[hidden email]> wrote:
>> I'll add an "include" or "only" option.
>
>Don't forget to commit http://trac.wordpress.org/ticket/2328 or
>something similar ;)

+1

I think that during this, every list tags should be reviewd and soem
hve to be harmonized, for example having a dropdonwn_archive that
generates the dropdown ad dropdown_cats would be nice too, sme for
links, harmonizing all the "list" tags it's a big and hard job but
having a more harmonized structures between various tag would be nice
woldn't be ?

--

Stefano Aglietti - StallonIt on IRCnet - ICQ#: 2078431
Email: [hidden email] [hidden email]
Sites: http://www.40annibuttati.it (personal blog)
       http://www.wordpress-it.it (WordPress Italia)
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

Ryan Boren
Stefano wrote:
> I think that during this, every list tags should be reviewd and soem
> hve to be harmonized, for example having a dropdonwn_archive that
> generates the dropdown ad dropdown_cats would be nice too, sme for
> links, harmonizing all the "list" tags it's a big and hard job but
> having a more harmonized structures between various tag would be nice
> woldn't be ?

I'm doing just that in svn trunk.  Take a look at
wp_dropdown_categories(), wp_list_categories(), wp_dropdown_pages(), and
wp_list_pages().  I'm working on wp_list_bookmarks() right now.  I'm
planning to harmonize the arguments passed to them while maintaining
backwards compatibility with old arguments.

Also note that you can call these functions in two different ways now.
You can use a query string:

wp_dropdown_categories('selected=34&hierarchical=1');

Or an associative array:

$args  = array('selected' => 34, 'hierarchical' => true);

wp_dropdown_categories($args);

Whichever you prefer. Sometimes the associative array is handy,
especially when using compact().  Sometimes you just want to
add_query_arg() onto a query string.

Help cleaning all of this up is appreciated, of course.  I'd like to get
an updated 'only' patch for get_categories(), get_pages(), and
get_bookmarks().  This stuff needs lots of testing too.

As for #2328, I think we can be even more comprehensive than that.
Let's make our hooks wish list for these functions.

Ryan
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: 2.next and categories functions

Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ryan Boren wrote:
> As for #2328, I think we can be even more comprehensive than that. Let's
> make our hooks wish list for these functions.

I don't think it's necessary to have lots of hooks, just one good hook in the right place.  As David
suggested, I'd like to see a filter on the actual array content, instead of just the
outputted text.  However, I argued that it would be more useful to have a filter before the
categories or pages are even fetched by WordPress, so that plugins can generate their own subset of
categories or posts according to more complex criteria without having to filter the full set of results.

Getting all categories then providing a filter means we have to unset those categories in the array
that we don't want.  This probably involves the plugin making its own db access, then unsetting each
element of the object array.  It would work, but it's not pretty.  Relying solely on 'exclusions' or
'only' means a plugin has to generate a long string of ids.  (Incidentally, in the exclusions logic,
would it be more efficient to use NOT IN(1,2,...) instead of AND cat_id <> 1 AND cat_id <> 2 ... ?
Not sure of the speed comparison).

This is a rough idea of what I'd like to see, for example, in get_category(), where $r is the
supplied args merged with defaults:

// Takes arguments and returns an OBJECT array of category data.
$categories = do_action('get_category', $r);

// WordPress retrieves the categories if the plugin didn't.
if (!$categories) $categories = $wpdb->get_results("...");

This can take place even before the 'exclusions' (and the presumed 'only') loop as long as the
plugin has access to the arguments and handles them.

Note that the check above is too simple and would have to include the possibility that the plugin
deliberately returned no categories.  This method avoids the need for multiple db accesses and also
allows plugins to do other things like alter the cat_name here, if they were able, instead of having
to update it later in list_cats.  Mainly, it gives access to the source of the data, the effects of
which will happen throughout the site and admin interface from only one plugin function.  Similar
functionality in pages and bookmarks would be great too.

Finally, for building a category or page list, it would good if the _page_dropdown_element etc
callback functions were pluggable so formatting could be controlled.  At the moment, access only to
the HTML, through the wp_list_pages filter is a bit clunky.

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFECXW0rovxfShShFARAizqAJ9qLdg1ev+uB1go7BDWd/C+w74hBwCfdEnc
m2jLUx7fj7X+pzxtRY+ALzU=
=JFE6
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers