|
Poslao: 31 Mar 2011 02:05
|
offline
- hnenad

- Građanin
- Pridružio: 30 Avg 2008
- Poruke: 91
|
Napisano: 31 Mar 2011 0:34
Pozdrav
da li google prihvata sitemap u php formatu?
<?
header("Content-type: text/xml");
echo'<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
echo' <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
$sql = mysql_query("select blah from bleh");
while ($string = mysql_fetch_array($sql)){?>
<url>
<loc>http://www.mojsajt.com</loc>
<changefreq>weekly</changefreq>
</url>
<? }?>
</urlset>
Dopuna: 31 Mar 2011 2:05
Pokušao sam i u webmaster toolsu mi je prihvatio ovako rešenje. Koje je vaše mišljenje o ovakom rešenju?
|
|
|
|
|
Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
|
|
|
Poslao: 31 Mar 2011 16:57
|
offline
- eevan79

- Građanin
- Pridružio: 21 Apr 2007
- Poruke: 98
|
Ako je prihvatio onda je ok. Mislim da google gleda sadržaj tvog fajla, a ne ekstenziju.
|
|
|
|
|
|
|
Poslao: 31 Mar 2011 19:04
|
offline
- Nikola04

- Građanin
- Niko E
- Software & Information Engineering
- Pridružio: 05 Maj 2009
- Poruke: 135
- Gde živiš: Wien
|
I ja imam slicno resenje, prihvaćeno. Cak su mi vise strana indeksirane iz php sitemapa neko iz XMLa.
|
|
|
|
|
|
|
Poslao: 31 Mar 2011 23:44
|
offline
- eevan79

- Građanin
- Pridružio: 21 Apr 2007
- Poruke: 98
|
Sad je pitanje koliko se to isplati...da svaki put "izvlačiš" sitemap iz baze kada te poseti crawler...pogotovo kada imaš puno naslova.
Zar ti nije lakše da rezultat snimiš kao .xml fajl, a sitemap ažuriraš ručno ili preko cron-a?
|
|
|
|
|
|
|
|
|
Poslao: 10 Jul 2011 20:55
|
offline
- lnenad

- Stručni saradnik
Web
- Pridružio: 16 Jan 2007
- Poruke: 2860
- Gde živiš: Bijeljina
|
Pa sam si napisao kod u prvoj poruci.
|
|
|
|
|
|
|
Poslao: 10 Jul 2011 22:43
|
offline
- hnenad

- Građanin
- Pridružio: 30 Avg 2008
- Poruke: 91
|
ne nisam na taj de mislio, nego me interesuje da li mogu da napravim xml sa php-om, npr. kada pravim folder onda upišem mkdir
|
|
|
|
|
|
|
Poslao: 10 Jul 2011 23:42
|
offline
- lnenad

- Stručni saradnik
Web
- Pridružio: 16 Jan 2007
- Poruke: 2860
- Gde živiš: Bijeljina
|
Zelis fajl da napravis, novi fajl ?
[Link mogu videti samo ulogovani korisnici]
Samo umjesto .txt ekstenzije stavis .xml i postujes pravila formatiranja xml dokumenata.
|
|
|
|
|
|
|
Poslao: 11 Jul 2011 19:15
|
offline
- hnenad

- Građanin
- Pridružio: 30 Avg 2008
- Poruke: 91
|
Hvala na pomoći, problem rešen
evo ako neko želi ovako nešto da uradi
sitemap u php-u
<?
header("Content-type: text/xml");
echo'<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
echo' <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
$sql = mysql_query("select blah from bleh");
while ($string = mysql_fetch_array($sql)){?>
<url>
<loc>http://www.mojsajt.com</loc>
<changefreq>weekly</changefreq>
</url>
<? }?>
</urlset>
ako želite napraviti sitemap.xml file onda to radite ovako (nisam ekspert možda postoji bolje rešenje)
$sqlCommand = "SELECT id, ostalo FROM tabela";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$myFile = "sitemap.xml";
$fh = fopen($myFile, 'w') or die("ne mogu da otvorim ovaj fajl");
$stringData = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
fwrite($fh, $stringData);
$stringData = '';
while ($row = mysqli_fetch_array($query)) {
$id = $row["id"];
$ostalo= $row["ostalo"];
$stringData .= '
<url>
<loc>mojastranica.com/' .$id. '</loc>
<lastmod>datum</lastmod>
<changefreq>monthly</changefreq>
<priority>0.9</priority>
</url>';
}
mysqli_free_result($query);
fwrite($fh, $stringData);
$stringData = "
</urlset>";
fwrite($fh, $stringData);
fclose($fh);
|
|
|
|
|
|