2012年10月12日 星期五

flash call js 居然一定要用localhost才能測試


//用flash IDE測試不出來 要用localhost的方式或是丟到網路上 反正就是要成為網路模式 不能本機測試
import flash.external.ExternalInterface;
stop();

ck_mc.addEventListener(MouseEvent.MOUSE_DOWN, overGameMc);
function overGameMc(e:MouseEvent){

//---確認是否能呼叫外部javascript--ok=>true,之後在執行mouseopen()方法;      
 trace('123');
ExternalInterface.call("cool");

}


        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script language="javascript" >

var flashvars = {};
var params = {};
var attributes = {};

params.allowscriptaccess = "always";
attributes.id = "as3_js";
swfobject.embedSWF("trace.swf", "alt", "450", "450", "10.0.0", false, flashvars, params, attributes);

function cool(){
alert("cool");
}


</script>


<div class="as3">
<div id="alt"></div>
</div>



2012年9月20日 星期四

將文字轉數值 parseInt

$("#draggable").css('top');//320px
parseInt($("#draggable").css('top'));//320

2012年9月19日 星期三

用margin:0 auto 置中 要指定該寬度


margin:0 auto;
width:27px;

//用margin:0 auto 置中 要指定該寬度 而不是指定父層

2012年9月11日 星期二

javascript只取數字 用正規表示


var str=$(".area_product").css('left');//出來會是312px
var reg=/[^\d]+/img;
str=str.replace(reg,"");
alert(str);//出來會是312

2012年9月4日 星期二

2012年8月17日 星期五

wordpress 後台更改選項或自製後台



//更改選單位置
function custom_menu_order($menu_order) {
if (!$menu_order) return true;
    return array(
        'index.php',    
        'edit.php',
'edit.php?post_type=services',
'edit.php?post_type=work',
'edit.php?post_type=page',
    );
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');

//更改底下說明
function change_footer_content() {
  echo '感謝您使用我們的系統. 如果您需要請聯繫我們, 很好設計(studio.goods@gmail.com).';
}
add_filter('admin_footer_text', 'change_footer_content');


//刪除不必要後台功能,但用了更改分類會中猴
/*function remove_menu_pages() {
remove_menu_page('link-manager.php');  
    remove_menu_page('edit-comments.php');  
}
add_action( 'admin_init', 'remove_menu_pages' );*/

wordpress 更多欄位請愛用Custom Fields(plugin)讓你無敵

wordpress 需要更多欄位請愛用Custom Fields(plugin)讓你無敵

例如
你需要很多複選框checkbox
你需要欄位可以選顏色 他就有colorpick

還有一個很賊的repeat fields可以再一則文章裡
上重複性的資料~~~多麼棒啊~但這要25美金~~我還沒買


wordpress 用了wp_query但卻跟基本設定的每頁數量不同,導致分頁pagenavi出錯

wordpress 用了wp_query但卻跟基本設定的每頁數量不同,導致分頁pagenavi出錯

舉例
我新創一個$wp_query


$wp_query = null;
$wp_query = new WP_Query();
$showposts = 2;
$args = array(
'post_type' => 'news_post',
'posts_per_page' => $showposts,
'paged' => $paged
);
query_posts($args);

然後在下面執行迴圈
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
//肚傷心

<?php endwhile ?>
<?php endif ?>

再來<?php native_pagenavi(); ?>//分頁導覽

但是我在基本後台管理設定 每頁出現9篇
而我這裡想要每頁出現2篇

我這個news_post只有4篇數量

開始出現bug了
第一頁會2篇 也有2分頁 很棒
但是按到第2頁時 出現404

後來搞很久才發現
wp會預設用台數量來使用
也就是第2頁時  他會2x9=18
但我並沒有18個品項我只有4個阿 於是就出現404

所以在國外找到解決辦法
http://wordpress.stackexchange.com/questions/7687/pagination-with-wp-query-is-buggy-working-for-some-pages-but-not-the-others

在function.php加入底下code


add_action( 'pre_get_posts', 'wpse7687_pre_get_posts' );
function wpse7687_pre_get_posts( &$wp_query ) {
  if ($wp_query->query_vars['category_name'] == 'latest-news'){
    $wp_query->query_vars['posts_per_page'] = 4;
  }
}

他們是這麼說的

wp會有預設的query,因此可以直接更改或替換query
所以上面的code就是
"當你下的$wp_query的category_name是'latest-news'時 就會自動替換成每頁4個"


wordpress 如果有用post_type 請愛用archive.php

wordpress 如果有用post_type 請愛用archive.php

而若使用post_type ,網址就是
xxx.com.tw/post_type的名稱/

xxx.com.tw/post_type的名稱/page/2
就不會跟
xxx.com.tw/ category /page/2
搞混了

wordpress WP_Query不同post type選擇內容


          <?php

            $args = array(
'post_type' =>'work',
                        'category_name' => $myCat_slug[$i],
'order' => 'ASC'
                        );
            $listQuery = new WP_Query( $args );
            ?>
             <?php
            query_posts('post_type=post');
            ?>

2012年8月9日 星期四

jquery 同時進行不同的動畫又不被取消或干擾



//同時進行不同的動畫又不被取消

alpha_40();

$("#about_content").animate({scrollTop: $('#about_human_WOW').offset().top-use_top_dis},{queue: false,duration: 3000,complete:function(){$("#goTop").fadeIn();}});



function alpha_40(){
$("#about_content").animate({opacity: 0.2},{queue: false,duration: 500,complete:function(){alpha_mid()}});
}
function alpha_mid(){
$("#about_content").animate({opacity: 0.2},{queue: false,duration: 2500,complete:function(){alpha_100()}});
}
function alpha_100(){
$("#about_content").animate({opacity: 1},{queue: false,duration:2000});
}


參考
http://alphasis.info/2011/09/jquery-api-animate-properties-options-queue/

2012年8月8日 星期三

CSS 上下置中


<style>
html,body{
margin:0;
height:100%;
width:100%;
}
#in_wrap{
margin:0 auto;
text-align:center;
}
</style>


<div id="in_wrap" class="greenBorder" style="display: table; width:800px;height: 100%; #position: relative; overflow: hidden;">
<div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">
<div class="greenBorder" style="#position: relative; #top: -50%; ">
這裡寫要使用的吧
</div>
</div>
</div>

2012年7月30日 星期一

wordpress顯示分類標題或slug(category name)


在single.php裡這樣用
<?php
$category = get_the_category();
echo $category[0]->slug ;
?>
在category.php裡這樣用
$current_category = single_cat_title("", false);

2012年7月19日 星期四

wordpress取得縮圖網址SRC(thumbnail)


<?php
    $domsxe = simplexml_load_string(get_the_post_thumbnail());
    $thumbnailsrc = $domsxe->attributes()->src;
 ?>


<?php if (has_post_thumbnail()){ ?>

<?php }?>

2012年7月17日 星期二

2012年6月19日 星期二

2012年6月12日 星期二

wordpress-plugin:滑過展開按鈕群Accordion Menu

這配合wordpress的選單級次選單的外掛也太好用了吧!!!
jQuery Vertical Accordion Menu
(滑過展開按鈕群)

2012年6月11日 星期一

wordpress enter輸入和br配合法

1.安裝TinyMCE advance

2.使用<?php echo nl2br(get_the_content()); ?>

3.可以正常使用enter(大斷) 和shift enter(小斷)

遠振資料庫 資料庫名稱-帳號-密碼要完全不一樣

遠振資料庫

資料庫名稱-帳號-密碼要完全不一樣
不然常常出現 連結mysql bug出問題

2012年5月30日 星期三

jquery取子項目的方式

$(this).find("img");

CSS選取最後一個物件


CSS 最後一個通常不想margin怎麼辦 又不想JQUERY,如果是CSS的話,可以唷!
<html>
<head>
<style type="text/css">
ul li:last-child
{
font-weight:bold
}
</style>
</head>
<body>
<ul>
<li>IE</li>
<li>Firefox</li>
<li>Safari</li>
</ul>
</body>
</html>

2012年5月23日 星期三

字左邊線 border-left 要跟字差不多高

字左邊框線 border-left 要跟字差不多高
可以使用line-height去調整

筆記

2012年5月16日 星期三

wordpress連續兩個query_post


要先new一個WP_Query出來使用
以下範例
<?php
// 僅顯示標籤帶有cooking的文章
$videoQuery = new WP_Query( 'tag=video' );
 ?>
 <?php

$args = array(
'category_name' => 'frash_news');
query_posts($args);
?>
<?php while ($videoQuery->have_posts()) : $videoQuery->the_post(); ?>
//這裡使用吧!!!!
 <?php endwhile; ?>

2012年5月15日 星期二

float排版造成高低落差請使用jquery.masonry

float排版造成高低落差,目前我這裡無解,
只能使用jquery.masonry拉
http://masonry.desandro.com/index.html

wordpress上使用jquery.masonry


<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.7.1.min.js"></script>
<?php wp_head(); ?>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.masonry.min.js"></script>

注意
jquery主體要在最上面
中間要是wp_head()
下方才能載入jquery.masonry.min.js


$(function(){
$('#news_container').masonry({
// options
itemSelector : '.news_col',
columnWidth : 295
 });
});

295是news_col這物件的寬+左右padding+左右margin


.news_col{
float:left;
background:#EFEFEF;
margin-bottom:15px;
margin-left:15px;
padding-left:10px;
padding-right:10px;
width:auto;
width:260px;


在wordpress裡的list(Category)頁就是category.php

archive.php : Archive/Category模板
這就是所謂的list頁面
只要存在這頁wordpress一吃到類似這種網址http://localhost/theme/category/分類名稱/
就會進入Category(category.php)

index.php (首頁)
category.php (分類頁面)
archive.php (彙整頁面)
search.php (搜尋結果頁面)

2012年5月9日 星期三

WordPress的the_date()同一天只顯示一次

WordPress的the_date()同一天只顯示一次
很奇怪
要用echo get_the_date();
或 the_time();

2012年4月30日 星期一

less 加減法注意

@width - @sqWidth;
減號前後一定要空格!!!!

內容有float時外框適應高度

當內容有float時 外框就不會自動感知高度了
此時請服用clearfix
.clearfix:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}

.clearfix {display: inline-block;}

/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */

在外框的class加上clearfix唷!


wordpress 下其他路徑使用內建functions

假設在theme/library/functions/下
想使用get_bloginfo( 'admin_email' );//等等之程式
請使用作者愚蠢的做法如下
require( $_SERVER['DOCUMENT_ROOT'].'/wp-load.php' ); //目前是用這愚蠢的招式
//然後就可以使用get_bloginfo();了

2012年4月11日 星期三

wordpress 使用 less

STEP1.
下載less.js(http://lesscss.org/)









STEP2.
在你使用的theme裡創建一個library資料夾
在library資料夾再建js與styles資料夾












STEP3

把樣板theme裡的functions.php 加入以下幾行code
注意less版本如果是新版,請將裡面的less-1.3.0.min.js改為你的版本
<?php
// Setting paths to the resources we will need later, js and styles
$path_to_js         = get_stylesheet_directory_uri() . '/library/js/';
$path_to_styles = get_stylesheet_directory_uri() . '/library/styles/';

// We don't want to load unnecessary things when browsing the Dashboard, right?
if ( ! is_admin() ) {

        function load_LESS() {

                // Retrieving the paths we set above
                global $path_to_js, $path_to_styles;

                // Actually printing the lines we need to load LESS in the HEAD
                print "\n<!-- Loading LESS styles and js -->\n";
                print "<link rel='stylesheet/less' id='style-less-css'  href='" . $path_to_styles . "style.less' type='text/css' media='screen, projection' />\n";
                print "<script type='text/javascript' src='" . $path_to_js . "less-1.3.0.min.js'></script>\n\n";
        }

        // Adding the action to the HEAD
        add_action( 'wp_head', 'load_LESS' );

} // END ! is_admin()
?>

在此注意由於css裡使用相對路徑所有 images資料夾都要丟進library/styles/裡
不然就是更改上面的/library/styles/路徑
筆者我本身是改成 get_stylesheet_directory_uri() . '/';


COOL 開始在library裡的styles裡style.less 使用吧!!!

原文出處
http://carlorizzante.com/2011/how-to-implement-less-in-wordpress-first-approach/

讓Dreamweaver也能看懂LESS

不好意思,小弟從以前中毒 阿杜比 很久了,因此總是逃不脫dreamweaver這IDE,如果有人能跟我說哪一款CSS IDE好用的話在下感激不盡。

跟大家分享,假如你也跟我一樣,是想要用Dreamweaver但又想用less的話,我們一起來讓讓Dreamweaver也能看懂LESS吧

只有兩個步驟

step1
win7示範 CS5示範
C:\Users\你的名稱\AppData\Roaming\Adobe\Dreamweaver CS5\zh_TW\Configuration
例如我是
C:\Users\happy\AppData\Roaming\Adobe\Dreamweaver CS5\zh_TW\Configuration

找到Extensions.txt打開後
看到
CSS:Style Sheets改成CSS,LESS:Style Sheets

step2
找到你安裝Dreamweaver的路徑
範例我安裝在D:
D:\Program Files\Adobe\Adobe Dreamweaver CS5\configuration\DocumentTypes
這個文件MMDocumentTypes.xml打開
約142行
找到
 documenttype id="CSS" internaltype="Text" winfileextension="css" macfileextension="css" file="Default.css" writebyteordermark="false" mimetype="text/css"
改成
documenttype id="CSS" internaltype="Text" winfileextension="css,less" macfileextension="css,less" file="Default.css" writebyteordermark="false" mimetype="text/css"


重新啟動Dreamweaver就可以打開.less檔案後編輯儲存拉

CS6多一步
C:\Users\happy\AppData\Roaming\Adobe\Dreamweaver CS6\zh_TW\Configuration\DocumentTypes

這個文件MMDocumentTypes.xml打開
約142行
找到
 documenttype id="CSS" internaltype="Text" winfileextension="css" macfileextension="css" file="Default.css" writebyteordermark="false" mimetype="text/css"
改成
documenttype id="CSS" internaltype="Text" winfileextension="css,less" macfileextension="css,less" file="Default.css" writebyteordermark="false" mimetype="text/css"


原文請參考
http://helpx.adobe.com/dreamweaver/kb/change-add-recognized-file-extensions.html

2012年2月29日 星期三

photoshop圖層特效只影響下一個圖層

圖層特效只影響下一個圖層
在特效圖層上按alt一下,然後不要壓住滑鼠左鍵,直接滑到欲影響的圖層會有兩個圈

2012年2月22日 星期三

FB讚要正常顯示人數

目前測試用舊方法比較OK
//STEP1<html xmlns="http://www.w3.org/1999/xhtml" >
//加上
xmlns:fb=http://www.facebook.com/2008/fbml
//STEP2重點來了 app_id要寫啊fb:admins要寫啊head裡
<meta property="fb:admins" content="1631065163" />
<meta property="fb:app_id" content="336316793079458" />
//沒有app_id或fb:admins來這裡創一個取得
https://developers.facebook.com/apps
//STEP3在body裡加
<div id="fb-root"></div>
<script src="http://connect.facebook.net/zh_TW/all.js"></script>
<script>
FB.init({
appId : '336316793079458(填上你的APP_ID)',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<fb:like href="<?php the_permalink(); ?>" layout="button_count" show_faces="false" action="like" colorscheme="light"></fb:like>

//FB被快取(CATCH)住了來這裡按偵錯即可取消快取
https://developers.facebook.com/tools/debug

自訂義英文標題欄位在編輯文章時出現

//找到佈景裡的function.php
//加上底下

//Custom EnglishTitle Widget
add_action('admin_menu', 'custom_EnTitle_hooks');
add_action('save_post', 'save_custom_EnTitle');
add_action('wp_head','insert_custom_EnTitle');
function custom_EnTitle_hooks() {
  add_meta_box('custom_EnTitle', '自訂英文標題', 'custom_EnTitle_input', 'post', 'normal', 'high');
  add_meta_box('custom_EnTitle', '自訂英文標題', 'custom_EnTitle_input', 'page', 'normal', 'high');
}
function custom_EnTitle_input() {
  global $post;
  echo '';
  echo '';
}
function save_custom_EnTitle($post_id) {
  if (!wp_verify_nonce($_POST['custom_EnTitle_noncename'], 'custom-EnTitle')) return $post_id;
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
  $custom_EnTitle = $_POST['custom_EnTitle'];
  update_post_meta($post_id, '_custom_EnTitle', $custom_EnTitle);
}
function insert_custom_EnTitle() {
  if (is_page() || is_single()) {
    if (have_posts()) : while (have_posts()) : the_post();
      endwhile; endif;
      rewind_posts();
  }
}

//在要使用的地方加上

2012年2月20日 星期一

影片心得

假設做720X480
圖片就至少要1024X683
這樣縮放才不會馬賽克,有空間縮放
premiere匯出的
H.264檔案品質720x480勝過microsoft AVI 的720x480
300MB檔案勝過3GB

2012年2月14日 星期二

favicon_在IE9





最後把做好的圖丟去http://www.favicon.cc/
生成.ico然後放上去IE要刪除快取一直重整吧

目前得知safari在中文網址後面無法出現圖示

2012年2月12日 星期日

size of 33554432

size of 33554432 bytes exhausted wp-admin/includes/media.php on line 502

改空間商的php.ini
memory_limit = 16M(系統預設值) 32M 72M

或是在wp-config.php裡新增一條
define('WP_MEMORY_LIMIT', '64M');
任何位置

Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@goodsdesign.liuhder.com.tw and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

搬移主機後如果這樣就改權限755

不要或排除該分類的文章出現在網頁上

query_posts('cat=-6')
使用負數即是不要該分類的文章出現在網頁上
也可以這樣
query_posts( 'cat=-1,-2,-3' );