Bookmarks on 2009-08-31

Posted on August 31, 2009, under ບຸກມາກ.

ສະສົມໄວ້ຈົນຄ້ານອ່ານ ຊິລຶບຖິ້ມກໍເສຍດາຍ ເກັບໄວ້ໃນນີ້ເພື່ອອາດໄດ້ມາຊອກອ່ານອີກດີກວ່າ..

Bookmarks on 2009-01-21

Posted on January 21, 2009, under ບຸກມາກ.

ມີຫຼາຍອັນຢາກອ່ານ ແຕ່ບໍ່ໄດ້ອ່ານເທື່ອ ກໍ່ເລີຍ bookmark ໄວ້ອີກຮອບ

ການ include ແລະ exclude ໃນ php

Posted on July 26, 2008, under ເທັກໂນໂລຢີ.

ພໍດີວ່າ ໄດ້ມີໂອກາດແກ້ໄຂ code ສຳຫລັບດຶງກະທູ້ຫລ້າສຸດໃນ phpBB3 ມາສະແດງນອກ structure ຂອງຕົວ phpBB3 ກໍ່ເລີຍຕ້ອງໄດ້ Googling ໄປເລື້ອຍ ຈົນພົບວ່າ ການຈະ fetch ຂໍ້ມູນໃນ database ມາສະແດງນັ້ນ ນອກຈາກຈະມີການໃຊ້

WHERE topic_approved=1

ແລ້ວ ກໍ່ຍັງສາມາດໃຊ້

AND forum_id != '13'

ເພື່ອຈະບອກວ່າ ບໍ່ຕ້ອງ fetch ຈາກບ່ອນນີ້ໄດ້ນຳ

ຕອນທຳອິດຄິດວ່າອາດຈະຕ້ອງໄດ້ຂຽນ

WHERE topic_approved=1 AND forum_id = 'x'

ໄປເລື້ອຍ ໆ ແຕ່ບໍ່ເອົາ forum_id ທີ່ເຮົາບໍ່ຕ້ອງການສະແດງ (ຫມາຍຄວາມວ່າໃຫ້ fetch ສະເພາະອັນທີ່ຢາກໄດ້) ແຕ່ວ່າ ໃນຂັ້ນປະຕິບັດແລ້ວ ທິດສະດີນີ້ໃຊ້ບໍ່ໄດ້ ຈະຕ້ອງໃຊ້ການ forum_id != ‘x’ ແທນ

ເທັກນິກນີ້ເປັນທຳມະດາຂອງຄົນຮຽນ php ທີ່ຈະຕ້ອງຮູ້ ແຕ່ບັງເອີນວ່າ ຂພຈ ບໍ່ເຄີຍຮຽນຂຽນ php ມາກ່ອນ ມັນຈຶ່ງເປັນຫຍັງທີ່ຍາກ ແລະໃຊ້ເວລາຫລາຍກວ່າຈະເຮັດໄດ້

ຂຽນມາຮອດນີ້ຫາກໍ່ສັງເກດວ່າ ໃນບລັອກກ່ອນຫນ້ານີ້ ເຄີຍຂຽນວິທີ exclude ໄວ້ຄືກັນ

WordPress Mu Recent posts

Posted on June 23, 2008, under ເທັກໂນໂລຢີ.

ຈົດໄວ້ກັນລືມ

ວິທີສະແດງ recent posts ໃນຫນ້າທຳອິດ ໃຊ້ code ນີ້

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
Plugin Name: WordPress MU Recent Posts
Plugin URI: http://atypicalhomeschool.net/wordpress-plugins/
Description: Retrieves a list of the most recent posts in a WordPress MU installation. Based on (Andrea - fill this in)
Author: Ron Rennick
Author URI: http://atypicalhomeschool.net/
*/
 
/*
Version: 0.31
Update Author: Sven Laqua
Update Author URI: http://www.sl-works.de/
*/
 
/*
Parameter explanations
$how_many: how many recent posts are being displayed
$how_long: time frame to choose recent posts from (in days)
$titleOnly: true (only title of post is displayed) OR false (title of post and name of blog are displayed)
$begin_wrap: customise the start html code to adapt to different themes
$end_wrap: customise the end html code to adapt to different themes
 
Sample call: ah_recent_posts_mu(5,30,true, '<li>', '</li>'); >> 5 most recent entries over the past 30 days, displaying titles only
*/
function ah_recent_posts_mu($how_many, $how_long, $titleOnly, $begin_wrap, $end_wrap) {
	global $wpdb;
	$counter = 0;
	// get a list of blogs in order of most recent update
	$blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE
	  public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND blog_id != '10' AND blog_id != '115' AND
		last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY)
		ORDER BY last_updated DESC");
 
	if ($blogs) {
		foreach ($blogs as $blog) {
			// we need _posts and _options tables for this to work
			$blogOptionsTable = "wp_".$blog."_options";
		    	$blogPostsTable = "wp_".$blog."_posts";
			$options = $wpdb->get_results("SELECT option_value FROM
				$blogOptionsTable WHERE option_name IN ('siteurl','blogname') 
				ORDER BY option_name DESC");
		       // we fetch the title and link for the latest post
			$thispost = $wpdb->get_results("SELECT post_title, guid 
				FROM $blogPostsTable WHERE post_status = 'publish' 
				AND post_type = 'post' AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY)
				ORDER BY id DESC LIMIT 0,1");
			// if it is found put it to the output
			if($thispost) {
				if ($titleOnly == false) {
					echo $begin_wrap.'<a href="'.$thispost[0]->guid
					.'">'.$thispost[0]->post_title.'</a> <br/> by <a href="'
					.$options[0]->option_value.'">'
					.$options[1]->option_value.'</a>'.$end_wrap;
					$counter++;
					} else {
						echo $begin_wrap.'<a href="'.$thispost[0]->guid
						.'">'.$thispost[0]->post_title.'</a>'.$end_wrap;
						$counter++;
					}
			}
			// don't go over the limit
			if($counter >= $how_many) { 
				break; 
			}
		}
	}
}
?>

ເບິ່ງແຖວທີ່ ໓໒ ບ່ອນນີ້ກຳຫນົດວ່າໃຫ້ສະແດງສະເພາະບລັອກທີ່ເປັນ public ສ່ວນ mature, spam, deleted ແມ່ນບໍ່ສະແດງ ແລະຍັງສາມາດສັ່ງ exclude ບລັອກທີ່ຕ້ອງການໄດ້ໂດຍໃຊ້ AND blog_id != ‘ໄອດີຂອງບລັອກ’

ປັບແລ້ວລະເອົາໄປໃສ່ໃນ mu-plugins ແລ້ວດຶງມາສະແດງໃນຫນ້າເວັບໂດຍໃຊ້

1
<?php ah_recent_posts_mu(10,30,true, '<li>', '</li>'); ?>

ກຳຫນົດປະລິມານຕາມນັ້ນໄດ້ເລີຍ