Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [klasa] Generator sitemapy
PiotrekM
post 7.05.2012, 22:34:16
Post #1





Grupa: Zarejestrowani
Postów: 130
Pomógł: 6
Dołączył: 20.12.2009

Ostrzeżenie: (0%)
-----


Prosta klasa do generowania sitemapy.

Klasa: http://pastebin.com/FmX4LwsY

Użycie:
  1.  
  2. $sitemap = new Sitemap_Generator;
  3. $sitemap -> set_last_mod_static(date('Y-m-d'));
  4. $sitemap -> set_base_url('http://example.pl/');
  5.  
  6. $sitemap -> add_site('rejestracja.html', array('changefreq' => 'never'));
  7. $sitemap -> add_site('logowanie.html', array('changefreq' => 'never'));
  8. $sitemap -> add_site('pomoc.html', array('changefreq' => 'never'));
  9. $sitemap -> add_site('stworz-fiszki.html', array('changefreq' => 'never'));
  10. $sitemap -> add_site('jak-dodawac-fiszki.html', array('changefreq' => 'never'));
  11.  
  12. $sitemap -> add_site('tagi.html', array('changefreq' => 'hourly'));
  13. $sitemap -> add_site('tag/angielski.html', array('changefreq' => 'hourly'));
  14. $sitemap -> add_site('tag/niemiecki.html', array('changefreq' => 'hourly'));
  15. $sitemap -> add_site('tag/francuski.html', array('changefreq' => 'hourly'));
  16. $sitemap -> add_site('tag/wloski.html', array('changefreq' => 'hourly'));
  17. $sitemap -> add_site('tag/lacina.html', array('changefreq' => 'hourly'));
  18. $sitemap -> add_site('tag/historia.html', array('changefreq' => 'hourly'));
  19. $sitemap -> add_site('tag/polski.html', array('changefreq' => 'hourly'));
  20. $sitemap -> add_site('tag/WOS.html', array('changefreq' => 'hourly'));
  21. $sitemap -> add_site('tag/prawo.html', array('changefreq' => 'hourly'));
  22. $sitemap -> add_site('tag/religia-i-etyka.html', array('changefreq' => 'hourly'));
  23. $sitemap -> add_site('tag/historia-sztuki.html', array('changefreq' => 'hourly'));
  24. $sitemap -> add_site('tag/geografia.html', array('changefreq' => 'hourly'));
  25. $sitemap -> add_site('tag/biologia.html', array('changefreq' => 'hourly'));
  26. $sitemap -> add_site('tag/medycyna.html', array('changefreq' => 'hourly'));
  27. $sitemap -> add_site('tag/chemia.html', array('changefreq' => 'hourly'));
  28. $sitemap -> add_site('tag/fizyka.html', array('changefreq' => 'hourly'));
  29. $sitemap -> add_site('tag/matematyka.html', array('changefreq' => 'hourly'));
  30. $sitemap -> add_site('tag/hobby.html', array('changefreq' => 'hourly'));
  31. $sitemap -> add_site('tag/design.html', array('changefreq' => 'hourly'));
  32. $sitemap -> add_site('tag/prawo-jazdy.html', array('changefreq' => 'hourly'));
  33.  
  34. echo $sitemap -> generate();
  35. #$sitemap -> download();
Go to the top of the page
+Quote Post
kwejkowo
post 16.06.2014, 00:43:12
Post #2





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 16.06.2014

Ostrzeżenie: (10%)
X----


Dałbyś radę poprawić sitemape aby sama dzieliła na pliki i budowała plik sitemap ze wszystkimi sitemapami ;P

np. mam 3mln rekordów chciałbym je wygenerować auto. ale tak że leci z foreach zapytania SQL żeby tych 2mln nie ładować bezpośrednio do pamięci.

Tzn. że co np. 10tyś musiałoby się zapisywać rekursywnie do pliku aż osiągnie 50tys i tworzy kolejny plik, a na końcu wypluwa jeden plik sitemap z linkami do reszty sitemap.

Ten post edytował kwejkowo 16.06.2014, 00:45:21
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 19:29