Hiç uğraşmaya gerek yok.
Veritabanı oluştur her sayfada da tek kodla veritabanındaki desc'leri çek.
PHP ile Static sayfada description tagı'na içerikten bir bölümü nasıl çekerim.
14
●735
- 20-09-2017, 16:54:47Üyeliği durduruldu
- 20-09-2017, 18:22:49Merhaba,DWather adlı üyeden alıntı: mesajı görüntüle
Evet static sayfalar html uzantılı. Tam olarak yapmak istediğim altdaki gibi.
<?php $metaDescription = substr(strip_tags(html_entity_decode($static["content"])),0,200) ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="<?php echo "$description";?>" /> </head> <body> <div class="content"> <p>The laws of England and Wales govern this agreement, without giving effect to conflict of laws provisions. The courts of England and Wales have exclusive jurisdiction over all disputes relating to or arising from the execution or performance of this agreement unless Agario wishes to initiate legal proceedings in your home legal district. In all judicial actions.</p> </div> </body> </html>
Böyle bir yöntem denedim ama sadece file_get_contents('sayfa.html'); şeklinde veri geliyor, yani url olarak yazdımmı site içinden veri gelmiyor "/" kabul etmiyor.
<?php $metaDescription = file_get_contents('http://<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; ?>'); preg_match('#<div class="content">\s+<p>(.*?)</p>\s+</div>#',$metaDescription,$al); echo $al [1]; ?> - 20-09-2017, 22:07:50Bütün html sayfaların header kısmı tek bir sayfadan geliyor "header.php" kod tek bir sayfaya eklenerek tüm sayfalarda gözükmesi gerekiyor bende sayfaları url'den çağırmak istedim.DWather adlı üyeden alıntı: mesajı görüntüle
- 20-09-2017, 22:27:55Kimlik doğrulama veya yönetimden onay bekliyor.DWather adlı üyeden alıntı: mesajı görüntüle
Çok pratik ve zekice bir cevap bence bunu kullanabilirsin. - 21-09-2017, 00:20:41Bu şekilde hallettim. yardımların için teşekkürler.DWather adlı üyeden alıntı: mesajı görüntüle
<?php $pageUrl = str_replace("/","","".$_SERVER['REQUEST_URI'].".html"); $descT = file_get_contents($pageUrl); preg_match('#<div class="content">\s+<p>(.*?)</p>\s+</div>#',$descT,$al); ?> <meta name="description" content="<?php echo mb_substr($al[1],0,158);?> ..." />