Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Kaynak ikonu

XF 2.2 Widget (weather for today)

indirmek için izniniz yok
Bu eklenti, add-ons XenForo 2.2.X ile uyumlu ve stabil olarak çalışmaktadır.
Uyumlu XF 2 Sürümleri
  1. 2.2.X
  2. 2.3.X

Weather for today​


1- Inspection after installation
1721972690721.webp

2- Before activating the code, I must register on the following site and obtain the API key number, then paste it into the code and the site as follows:


3- The code after modification includes the API key, noting that this key is temporary and will expire. If you want to get a fixed number, you must subscribe or to get new free number for testing. The subscription plans are available on the site above.

Kod:
<head>
    <style>
        .weather-widget {
            width: 230px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            font-family: Arial, sans-serif;
        }
        .weather-header {
            text-align: center;
            margin-bottom: 10px;
        }
        .weather-icon {
            text-align: center;
            margin-bottom: 10px;
        }
        .weather-temp {
            text-align: center;
            font-size: 2em;
            margin-bottom: 10px;
        }
        .weather-description {
            text-align: center;
            margin-bottom: 10px;
        }
        .weather-location {
            text-align: center;
            font-size: 1.2em;
            color: #666;
        }
    </style>
</head>
<body>

<div class="weather-widget" id="weather-widget">
    <div class="weather-header">
        <h3>Weather for today</h3>
    </div>
    <div class="weather-icon" id="weather-icon">
    </div>
    <div class="weather-temp" id="weather-temp">
    </div>
    <div class="weather-description" id="weather-description">
    </div>
    <div class="weather-location" id="weather-location">
    </div>
</div>

<script>
    async function fetchWeatherData() {
        try {
            const ipResponse = await fetch('https://api.ipify.org?format=json');
            const ipData = await ipResponse.json();
            const ip = ipData.ip;
            const locationResponse = await fetch(`https://ipapi.co/${ip}/json/`);
            const locationData = await locationResponse.json();
            const { city, region, country, latitude, longitude } = locationData;
            const apiKey = 'd70b8b23979603a237cb3f4f86dd1921';  // Replace your OpenWeatherMap API key
            const weatherResponse = await fetch(`https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&units=metric&lang=ru&appid=${apiKey}`);
            const weatherData = await weatherResponse.json();
            const { weather, main } = weatherData;
            document.getElementById('weather-icon').innerHTML = `<img src="https://openweathermap.org/img/wn/${weather[0].icon}@2x.png" alt="Weather icon">`;
            document.getElementById('weather-temp').innerText = `${main.temp} °C`;
      
            document.getElementById('weather-location').innerText = `${city}, ${country}`;
        } catch (error) {
            console.error("Error while retrieving weather data: ", error);
            document.getElementById('weather-widget').innerText = 'Failed to load weather data.';
        }
    }
    fetchWeatherData();
</script>
</body>

4- Explanation of the structure and some modifications to the code:

A- Through the control panel >> Appearance >> Add a widget >> then define the widget, we choose HTML
B- At the widget key, we write weather.
C- In the title, write what you want, for example, the weather condition.
D- When displaying the positions, we choose the forums list: sidebar
E- In the template, put the above code
F- If you want to activate (advanced mode), you must adjust the following display dimensions in the image from 250 to 230.
1721972831034.webp

G- If the advanced topic is activated, the image will be as follows:
1721972853225.webp
Yazar
Binkaddas
İndirilme
4
Görüntüleme
278
İlk yayınlama
Son güncelleme

Puanlar

0,00 yıldız 0 değerlendirme

Tema özelleştirme sistemi

Bu menüden forum temasının bazı alanlarını kendinize özel olarak düzenleye bilirsiniz.

Zevkine göre renk kombinasyonunu belirle

Tam ekran yada dar ekran

Temanızın gövde büyüklüğünü sevkiniz, ihtiyacınıza göre dar yada geniş olarak kulana bilirsiniz.

Izgara yada normal mod

Temanızda forum listeleme yapısını ızgara yapısında yada normal yapıda listemek için kullanabilirsiniz.

Forum arkaplan resimleri

Forum arkaplanlarına eklenmiş olan resimlerinin kontrolü senin elinde, resimleri aç/kapat

Sidebar blogunu kapat/aç

Forumun kalabalığında kurtulmak için sidebar (kenar çubuğunu) açıp/kapatarak gereksiz kalabalıklardan kurtula bilirsiniz.

Yapışkan sidebar kapat/aç

Yapışkan sidebar ile sidebar alanını daha hızlı ve verimli kullanabilirsiniz.

Radius aç/kapat

Blok köşelerinde bulunan kıvrımları kapat/aç bu şekilde tarzını yansıt.

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Geri