[Lyceum-dev] Widgets: MyBlogs and All Blogs
DaveG
lyceum at solidgone.com
Sun Jul 30 22:42:36 EDT 2006
I'm trying to create two widgets. One to show all the current users
blogs, and one to show all blogs. I've successfully created a "hello
world" widget, so my widget base is okay.
I was thinking of using the existing code in /default/sidebar.php.
However moving this into the widget fails. I believe it's the very first
statement that's the problem, which suggests that there are some
functions out of scope.
1] Is there someway to bring the functions in scope?
2] A better approach might be to make the code into Lyceum functions
rather than hard coding in /default/sidebar.php, and then calling the
functions from the sidebar. If I did that would the functions be in
scope, or am I back to problem 1?
3] Is there a better approach I should take?
~ ~ Dave
-------- SNIPET for ALL_BLOGS widget ---------
echo $before_widget;
//----------------
$wpdb->query("
CREATE TEMPORARY TABLE bloginfo
SELECT $wpdb->blogs.id, $wpdb->blogs.slug, option_value as
blogname, status
FROM $wpdb->blogs
INNER JOIN $wpdb->options ON ($wpdb->blogs.id =
$wpdb->options.blog)
INNER JOIN $wpdb->posts
INNER JOIN $wpdb->post2cat ON (post_id = $wpdb->posts.ID)
INNER JOIN $wpdb->categories ON (category_id = cat_ID AND
$wpdb->categories.blog = $wpdb->options.blog)
WHERE
status = 'active' AND
option_name = 'blogname'
ORDER BY post_date_gmt DESC
");
$blogs = $wpdb->get_results("SELECT DISTINCT(id), slug, blogname,
status FROM bloginfo");
echo $before_title . $title . $after_title;
if ($blogs)
if(SUBDOMAINS)
foreach ($blogs as $b)
echo "<a
href=\"http://$b->slug.".MAINDOMAIN."\">$b->blogname</a>";
else
foreach ($blogs as $b)
echo "<a href=\"./$b->slug\">$b->blogname</a>";
//----------------
echo $after_widget;
More information about the Lyceum-dev
mailing list