Skip to Content.
Sympa Menu

lyceum-dev - Re: [Lyceum-dev] Widgets: MyBlogs and All Blogs

lyceum-dev AT lists.ibiblio.org

Subject: Lyceum-dev mailing list

List archive

Chronological Thread  
  • From: Jameson Lopp <fusion AT ibiblio.org>
  • To: DaveG <lyceum AT solidgone.com>
  • Cc: lyceum-dev AT lists.ibiblio.org
  • Subject: Re: [Lyceum-dev] Widgets: MyBlogs and All Blogs
  • Date: Sun, 30 Jul 2006 22:47:52 -0400

$wpdb is a global variable, so before you start using it you should have the statement:

global $wpdb;

Hopefully that's the only problem with the code :-P

- Jameson

DaveG wrote:
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;

_______________________________________________
Lyceum-dev mailing list
Lyceum-dev AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/lyceum-dev





Archive powered by MHonArc 2.6.24.

Top of Page