Bir web sayfasına mini yönetici ekleme

0 Cevap php

Picture this: you are creating a little module that people can incorporate into their website easily, for example, a little contact form. It would consist of a PHPfile that outputs some HTML, a Javascript file (ajax etc.), a CSS file and a CSS skin. Now the person who doesn't know much about coding wants to integrate it on a webpage (website/index.php). We could do this with three rules of code:

<link rel="stylesheet" href="module/css/module.css" />
<script src="module/js/module.js"></script>
<?php require_once 'module/module.php'; ?>

Bu kısım şüpheli olduğuna şüphe var, tamam mı?

Bu küçük modül için bir yönetici eklemek istediğiniz zaman, şimdi iki seçenek vardır:

  1. Accessing the admin via an extra URL like website/module/admin.php and after authentication, displaying a page where the person can do all the settings. The person then goes back to index.php to see the results.
  2. Enabling the admin via an extra URL like website/module/admin.php and after authentication, redirecting back to index.php. The person can now edit the module directly (HTML5 contenteditable) and see changes live, on the webpage where everybody else will see it when the person saves the changes.

Seçenek 2 avantaj bir çift var:

  • The person admin ve index.php arasında geçiş yapmak zorunda değildir.
  • The person o içeri entegre oluyor web sayfasına bakıyor doğrudan görebilirsiniz
  • Modülü web sayfası / web sitesinin daha parçası gibi The person muhtemelen hissediyor.

Tabii seçenek 2 de bazı dezavantajları vardır:

  • Her şey inline düzenleyerek iyi çalışıyor.
  • Kişi bir HTML5 uyumlu bir tarayıcı olması gerekir.
  • Muhtemelen biraz daha ben şimdi düşünüyorum olamaz.

Şimdi ben net bir cevap görmek gibi olamaz adlı bir kaç çekincem var.

  1. How would we let the person integrate the admin on their webpage? The admin files only need to be included in index.php if the person has choosen to edit the module via the url (website/module/admin.php). But how can we do this if we have a admin.css file that belongs in the head section, an admin.php file that goes into the body, and another admin.js file that's included at the end of the body?
  2. How would we know the file that admin.php needs to redirect back to, after authentication? index.php could be any webpage with any name. Answer: <?php echo $_SERVER['PHP_SELF']; ?>

Any real life website/web apps examples using this principle are welcome too. If there's something unclear, I am glad to add additional info.

0 Cevap