o / sitemap-php

Library for generating Google sitemap XML files
MIT License
300 stars 177 forks source link

error #5

Closed cocojambo89 closed 10 years ago

cocojambo89 commented 10 years ago

Hello,

I download this sitemap.php, upload in my public folder, when i run sitemap.php nothing happend, in error_log file i see this error

PHP Parse error: syntax error, unexpected '=', expecting function (T_FUNCTION) in /home/domain/public_html/Sitemap.php on line 23

How i can fix this ?

Thanks.

evert commented 10 years ago

Line 23 in Sitemap.php looks like this:

private $domain;

There's no equals sign (=) in there. Is that file broken or corrupted? What's on your line 23?

cocojambo89 commented 10 years ago

private $domain = 'http://www.domain.com';

now when i run domain.com/sitemap.php don't show error just blank page and not make error_log but i don't see sitemap.xml which need to be generated ?

Thanks.

evert commented 10 years ago

You shouldn't manually change the class, that's not how classes are supposed to be used. You don't run the class, there's just a class definition, nothing more.

Take a look at the readme in this repository to figure out how you're supposed to use this tool.

cocojambo89 commented 10 years ago

i check readme but really not understand what i need to edit in sitemap.php, can you please suggest me what i need to edit for this work ? this is how i imagine this, i run this, this will grab all links from my website and generate xml sitemp, true or not ?

Thanks.

evert commented 10 years ago

Hi @marii89

The readme says that you need to create a new php file and start with these two lines:

include 'Sitemap.php';
$sitemap = new Sitemap('http://example.com');

You don't edit any files.

cocojambo89 commented 10 years ago

Hi @evert I make new php file, run.php

<?php include 'Sitemap.php'; $sitemap = new Sitemap('http://domain.com'); ?>

When i run (domain.com/run.php) just show me blank page, xml files not generated ?

Thanks.

evert commented 10 years ago

That's how the readme starts. Read the entire document, don't just copy what I said.

cocojambo89 commented 10 years ago

I need add something more in this run.php ? I see there bellow is more description but i don't understand where i need to add e.g.

$sitemap->setPath('xmls/');

in sitemap.php or my run.php ?

Thanks.

evert commented 10 years ago

There is only one place where it would make sense to write that line of code, because there's only one place in your code where you have defined $sitemap.

Based on that, can you figure out what the most logical place is for that line of code?

cocojambo89 commented 10 years ago

you say i don't need edit Sitemap.php ? i need to add all this:

$sitemap->setPath('xmls/');

In my run.php ? Thanks.

evert commented 10 years ago

Yes, that is the next step. Remember that your run.php is the only place that has $sitemap defined, and that you never edit Sitemap.php

cocojambo89 commented 10 years ago

Now i edit run.php

<?php include 'Sitemap.php'; $sitemap = new Sitemap('http://domain.com'); $sitemap->setPath('xmls/'); $sitemap->setFilename('sitemap'); $sitemap->addItem('/', '1.0', 'daily', 'Today'); $sitemap->addItem('/otherpage'); $sitemap->setDomain('http://domain.com'); $sitemap->createSitemapIndex('http://domain.com/sitemap/', 'Today'); ?>

and i create in /xmls sitemap.xml and sitemap-index.xml but there is not links from my website, i guess this need crawl my website and save all links ? this save just

<?xml version="1.0" encoding="UTF-8"?>

http://domain.com/ 1.0 daily 2014-11-23 http://domain.com/otherpage 0.5
evert commented 10 years ago

Indeed, it is up to you to manually add all the pages. This tool helps you create the xml, it does not crawl your website for you.

cocojambo89 commented 10 years ago

:smiley: ok thanks a lot man on help :+1: