Site Sayfaları
Sayfa, sözleşme, haber, blog ve referans içeriklerini yöneten yedi uç.
Genel Bakış
Panelin Sayfalar, Sözleşmeler, Haberler, Bloglar ve Referanslar sekmelerinin hepsi tek bir içerik tipidir. Beşi de bu yedi uçtan yönetilir; aralarındaki tek fark gönderdiğiniz tip alanıdır.
İçerik dil başına tutulur: başlık, adres, gövde ve arama motoru alanları her dilde ayrı yaşar. Liste ucu geçerli dili verir, detay ucu hepsini; çeviri gerektiren her iş detaydan başlar.
Görseller ayrı uçlardan yüklenir ve tür ile adlandırılır. Hangi türün geçerli olduğu sayfanın tipine bağlıdır, bu yüzden aynı çağrı bir tipte çalışıp diğerinde reddedilebilir.
Referans
Sayfaları Listeleme
Seçtiğiniz içerik tipindeki sayfaları döndürür.
normal, contract, news, articles, references. Öntanımlı olarak düz sayfa.curl 'https://panel.ornek.com/api/v1/admin/website/pages?type=news&limit=25' \
-H "Authorization: Bearer $API_KEY"const url = new URL('https://panel.ornek.com/api/v1/admin/website/pages');
url.searchParams.set('type', 'news');
const res = await fetch(url, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages?' . http_build_query(['type' => 'news', 'limit' => 25]));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Tip verilmezse yalniz DUZ sayfalar doner; haberler ayri bir listede degil, ayni ucta.
$news = Api::Website()->GetPages([], ['type' => 'news'])['data'];Sayfa Detayı
Tek bir sayfayı bütün dilleri ve görselleriyle döndürür.
normal, contract, news, articles, references.curl 'https://panel.ornek.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/admin/website/pages/${id}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Liste TEK DIL verir, detay HEPSINI; ceviri gerektiren her is detaydan baslar.
$page = Api::Website()->GetPage(['id' => $id])['data'];
$en = $page['languages']['en'] ?? null;Sayfa Oluşturma
Yeni bir sayfa açar ve dillerini yazar.
normal, contract, news, articles, references. Sonradan değiştirilemez.curl -X POST 'https://panel.ornek.com/api/v1/admin/website/pages' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"type":"normal","languages":{"tr":{"title":"Hakkimizda","content":"<p>Merhaba</p>"}}}'const res = await fetch('https://panel.ornek.com/api/v1/admin/website/pages', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
type: 'normal',
languages: {
en: { title: 'About Us', content: '<p>Hello</p>' },
},
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'type' => 'normal',
'languages' => ['en' => ['title' => 'About Us', 'content' => '<p>Hello</p>']],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Adres verilmezse basliktan uretilir; ayni dilde carpisirsa cagri 422 ile doner.
Api::Website()->CreatePage([
'type' => 'news',
'languages' => ['en' => ['title' => 'Maintenance notice']],
]);Sayfayı Güncelleme
Sayfanın gönderdiğiniz alanlarını ve dillerini değiştirir.
curl -X PATCH 'https://panel.ornek.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"inactive","languages":{"tr":{"title":"Sirketimiz"}}}'const res = await fetch(`https://panel.ornek.com/api/v1/admin/website/pages/${id}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
status: 'inactive',
languages: { en: { title: 'About Our Company' } },
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'status' => 'inactive',
'languages' => ['en' => ['title' => 'About Our Company']],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yalniz gonderilen dil yazilir, digerleri KORUNUR; tip alani yoksayilir.
Api::Website()->UpdatePage([
'id' => $id,
'languages' => ['en' => ['title' => 'About Our Company']],
]);Sayfayı Silme
Sayfayı bütün dilleriyle kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/website/pages/5' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/admin/website/pages/${id}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yayindan kaldirmak icin silmek yerine DURUMU kapatin: adres ve gecmis korunur.
Api::Website()->UpdatePage(['id' => $id, 'status' => 'inactive']);Sayfa Görseli Yükleme
Bir sayfa görselini yükler ve öncekinin yerine koyar.
header-background, cover, mockup. Kapak türü haber, blog ve referansta; maket türü ise referansta geçerli.curl -X PUT 'https://panel.ornek.com/api/v1/admin/website/pages/5/images/header-background' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"https://ornek.com/afis.jpg"}'const res = await fetch(`https://panel.ornek.com/api/v1/admin/website/pages/${id}/images/header-background`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ image: 'https://example.com/banner.jpg' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages/' . $id . '/images/header-background');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['image' => 'https://example.com/banner.jpg']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Kapak ve maket turleri kucuk resmi de URETIR; afis turu tek dosya birakir.
Api::Website()->UploadPageImage([
'id' => $id, 'kind' => 'cover', 'image' => $data,
]);Sayfa Görselini Kaldırma
Bir sayfa görselini ve varsa küçük resmini kaldırır.
header-background, cover, mockup.curl -X DELETE 'https://panel.ornek.com/api/v1/admin/website/pages/5/images/header-background' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/admin/website/pages/${id}/images/header-background`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/website/pages/' . $id . '/images/header-background');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Gorseli DEGISTIRMEK icin once silmeye gerek yok; yukleme zaten yerine koyar.
Api::Website()->DeletePageImage(['id' => $id, 'kind' => 'cover']);Tuzaklar
İçerik tipi kaydın kimliğinin bir parçasıdır ve güncelleme onu yoksayar. Düz sayfa olarak açılmış bir kaydı habere çeviremezsiniz; doğru tiple yeniden oluşturup eskisini kaldırmanız gerekir. Tip yanlış girildiğinde bu, adresin ve görsellerin de yeniden kurulması demektir.
Aynı adres farklı dillerde yan yana durabilir, ama tek bir dilde iki sayfa aynı adresi taşıyamaz. Çakışma hatası hangi dilde olduğunu söyler. Adres göndermezseniz başlıktan üretilir; benzer başlıklı iki haber bu yüzden beklenmedik bir çakışma yaratabilir.
Afiş görseli her tipte geçerlidir; kapak haber, blog ve referansta, maket ise referansta kabul edilir. Uymayan bir tür 422 ile döner. Bu sayfa oluştururken de geçerlidir: gövdeye konan geçersiz bir görsel türü sayfanın hiç oluşmamasına yol açar.
Sözleşmenin onay seçenekleri, haberin müşteri panelinde görünmesi ve referansın sırası ile adresi kendi tiplerinde iş görür. Başka bir tipte gönderilirse hata alınmaz, değer de bir işe yaramaz. Beklediğiniz davranış çıkmıyorsa önce kaydın tipini doğrulayın.
Güncellemede gönderdiğiniz diller yazılır, göndermedikleriniz korunur. Yani tek bir dili düzeltmek için diğerlerini taşımanız gerekmez. Bu, sitenin diğer bazı yazma uçlarından farklıdır; oralarda gövde tanımın tamamı sayılır ve eksik bırakılan silinir.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.