我的表達方式可能有點差...我把CODE貼出來好了,這是現在在RUN的頁面 http://waaagh.ws/galley/20110416-%E5%8C%97%E5%AE%9C%E8%B2%A1%E8%8C%82%E7... <?php
// Get the xml of the feed provided in $url
$url = "http://picasaweb.google.com/data/feed/base/user/cstony0917/albumid/5596072560939078545?alt=rss&kind=photo&authkey=Gv1sRgCJTnv9OX5cfLNA&hl=zh_TW";
$cid = $url;
#echo '
';
#print_r(cache_get($cid));
if(!cache_get($cid)){
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
cache_set($cid,$response,'cache');
}else{
$response = cache_get($cid)->data;
}
$xml = simplexml_load_string($response);
$items = $xml->channel;
$page_count = 20;
$start = 0;
$start = $_GET['p'] * $page_count;
$photo = array();
$item_count =0;
foreach ($items->item as $item){
$title = $item->title;
$content = $item->description;
#echo $i. '';
// The Dirty Work!
//
// Pull the images from the *description* section
//
$quotes = array('"', "'", "\n");
$imgContents = str_replace($quotes, '', $content); # Strip " and ' as well as \n from input string
$imgContents = stristr($imgContents, 'src='); # Drop everything before the 'src'
$endTagPosition = strpos($imgContents, 'alt='); # Position of the end tag '>'
$img = substr($imgContents, 4, $endTagPosition - 5); # Get everything from src to end tag --> 'src="path" something>'
// Swap out the s288 from the small image to make the thumbnail and larger images
//
$img144 = str_replace('/s288', '/s144', $img);
$img800 = str_replace('/s288', '/s1024', $img);
$download = str_replace('/s288', '/d', $img);
$photo[$item_count]['title'] = $title;
$photo[$item_count]['thumb'] = $img144;
$photo[$item_count]['large'] = $img800;
$photo[$item_count]['download'] = $download;
$item_count ++;
}
$end = $start + $page_count;
if($end > $item_count) $end = $item_count;
?>
Re: 想要讓一個CUSTOM ...
是有現成模組,但以開發來談。。。
新開 CONTENT TYPES 暫時可以略過使過代碼建立,你可以手動在此新增一個:
/#overlay=admin/structure/types/add
(透過代碼建的話比較煩,不是對外發放,最好不要令自己麻煩,其中一個可以參考:
http://api.drupal.org/api/drupal/developer--hooks--node.php/function/hoo...)
再來就透過 node_save 儲蓄東西:
http://api.drupal.org/api/drupal/modules--node--node.module/function/nod...
(http://www.notabluescreen.com/create-node-migrating-site)
其實,你要是做即時輸出,對保存內容不著重,直接或者 JS 更快更好,否則,在NODE才處理好像有點怪
---
notaBlueScreen
Re: 想要讓一個CUSTOM ...
我是想說如果作成模組可以省掉每次COPY CODE的動作...又可以分享給大家來使用
我的表達方式可能有點差...我把CODE貼出來好了,這是現在在RUN的頁面
http://waaagh.ws/galley/20110416-%E5%8C%97%E5%AE%9C%E8%B2%A1%E8%8C%82%E7...
<?php
// Get the xml of the feed provided in $url
$url = "http://picasaweb.google.com/data/feed/base/user/cstony0917/albumid/5596072560939078545?alt=rss&kind=photo&authkey=Gv1sRgCJTnv9OX5cfLNA&hl=zh_TW";
$cid = $url;
#echo '
Re: 想要讓一個CUSTOM ...
我找到了這個模組可以達到我的需求,看到模組簡介的時候我整個超感動的!!
http://drupal.org/project/custom_formatters
這根本就是我要的啊!!!!Orz