need assistance with theme tweaking after tags migration

1 view
Skip to first unread message

Andy C

unread,
Dec 4, 2009, 3:17:46 PM12/4/09
to habari-users
Just sync'ed to r3855 and I need some help with some code in my
Whitespace theme that manipulates the database directly. Tsk, tsk.

if( !$this->template_engine->assigned( 'tags' ) ) {
$tags= DB::get_results( 'SELECT * FROM ' . DB::table
('tags') );
$tags= array_filter($tags, create_function('$tag', 'return
(Posts::count_by_tag($tag->tag_slug, "published") > 0);'));
$this->assign('tags', $tags);
}

I presume this block can be simplified now.

If you're wondering why I am incapable of fixing this trivial issue,
given I wrote it myself, well I didn't write it myself, I mindlessly
plagiarised the code from Michael's port of the WP Connections
theme :-)

rick c

unread,
Dec 4, 2009, 8:19:20 PM12/4/09
to habari-users
Andy C,

I think this will work:

if( ! $this->template_engine->assigned( 'tags' ) ) {
$tags = array_filter( Tags::get(), create_function( '$tag', 'return
( Posts::count_by_tag( $tag->tag_text, "published" ) > 0);' ) );
$this->assign('tags', $tags);
}

Rick

Andy C

unread,
Dec 5, 2009, 3:40:56 AM12/5/09
to habari-users
Many thanks, Rick.

You're probably expecting me to say 'Works fine'. However when I
delved deeper, this array wasn't even used. It was some legacy cruft I
inherited when plagiarising the theme way back when.

However, I'm sure it does work and hope the tip may prove useful to
someone else.
--
Andy

rick c

unread,
Dec 5, 2009, 10:18:34 AM12/5/09
to habari-users
That's even better. You can strip it out completely. :)

Rick
Reply all
Reply to author
Forward
0 new messages