2011-05-05 181 views
0

我真正想要做的就是將Google的路徑替換爲我的路徑。用custome圖片路徑替換默認圖片路徑

//從模塊

$today = &$handler->current_conditions; 
$condition = (string) $today->condition->attributes()->data; 

$unit = google_weather_get_unit($convert_to); 

$icon_src = (string) $today->icon->attributes()->data; 
$content['current'] = array(
    'temp' => $convert_to == 'SI' ? (string) $today->temp_c->attributes()->data . $unit : (string) $today->temp_f->attributes()->data . $unit, 
    'humidity' => (string) $today->humidity->attributes()->data, 
    'icon' => theme('image', 'http://www.google.com' . $icon_src, $condition, $condition, NULL, FALSE), 
    'condition' => $condition, 
    'wind_condition' => (string) $today->wind_condition->attributes()->data, 
    'custompath'=> $icon_src, 
); 

//代碼代碼tpl.php

<div class="weather-icon float-left"> 
    // <?php print $content['current']['icon']; ?> 
    <?php print $base_url; ?> 
    <?php print $content['current']['custompath']; ?> 
</div> 

回答

2

你就不能使用str_replace函數?例如,如果現在說http://www.google.com/images/icon.png,你需要http://www.myhost.com/images/icon.png

<?php print str_replace("www.google.com", "www.myhost.com", $content['current']['icon']); ?> 
+0

str_replace函數聽起來很酷,但他們的路徑是從mine..say不同的是他們/天氣/ IG /圖像和礦完全是另一回事?多數民衆贊成在什麼我真的需要做..感謝 – gables20 2011-05-06 06:11:02

+0

如果你想要你可以使用完全不同的路徑:'str_replace(「http://www.google.com/weather/ig/images/」,「http:// www.mysite.com/another/structure/images/「,$ content ['current'] ['icon']);'這不僅僅是你可以改變的域名,你也可以改變整個目錄結構,不必匹配。它只是搜索第一個字符串,並用第二個字符串替換它。看看http://php.net/manual/en/function.str-replace.php – 2011-05-06 09:29:55

+0

非常感謝你,我已經得到它現在的工作... !!!! – gables20 2011-05-06 10:48:14