Can't view sitemap

Permalink
I installed C5 and have been trying to delete all the pages and start fresh (wanna see how that works out)

But my sitemap won't show anything, searching doesn't give anything either.

I'm running a linux gentoo machine with minimal installation of php and apache2 (which could explain the problem)

Are their any components that c5 uses or am I doing something wrong?

My sitemap.xml exists and I just did a Maintenence on it. (refreshed just in case it was a cache problem, nothing...)

View Replies:
BinarySpike replied on at Permalink Reply
by the way, you can login
http://home.binaryspike.com/concrete5.0.0/...

user: test
pass: testuser

goto sitemap in the dashboard and it's empty for me.
andrew replied on at Permalink Reply
andrew
This function is native to PHP 5.2.

I believe a drop in replacement is available pretty easily. You could probably grab it and add it to index.php in your root. Just

function json_encode($val) {
    ....
}


I believe there are some available here:

http://us3.php.net/json_encode
vercasson replied on at Permalink Reply
vercasson
function json_encode($a)
{
if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a)) {
$a = addslashes($a);
$a = str_replace("\n", '\n', $a);
$a = str_replace("\r", '\r', $a);
$a = preg_replace('{(</)(script)}i', "$1'+'$2", $a);
return "'$a'";
}
$isList = true;
for ($i=0, reset($a); $i<count($a); $i++, next($a))
if (key($a) !== $i) { $isList = false; break; }
$result = array();
if ($isList) {
foreach ($a as $v) $result[] = json_encode($v);
return '[ ' . join(', ', $result) . ' ]';
} else {
foreach ($a as $k=>$v)
$result[] = json_encode($k) . ': ' . json_encode($v);
return '{ ' . join(', ', $result) . ' }';
}
}
andrew replied on at Permalink Reply
andrew
Technically this probably means that we should be requiring PHP 5.2 or higher...but I've encountered a lot of environments that have this function native that are older than 5.2. Maybe we should just include a drop-in function if json_encode isn't native.
BinarySpike replied on at Permalink Reply
Well it would at least be nice if there was some sort of complaint from c5 on this issue.

My gentoo server doesn't have the json use flag for php, I'm enabling it now.
BinarySpike replied on at Permalink Reply
Well someone logged into my site and messed with things from this post =-P

Pretty funny hehe

Also, I added the JSON use flag to my gentoo /etc/make.conf, re-compile php, and restarted apache2 and the sitemap is working great.

Thanks andrew!
jnichols437 replied on at Permalink Reply
I'm having the same issue with not being able to see my site map. Godaddy is my host.

Which file needs to have this function included? Thanks,
jnichols437 replied on at Permalink Reply
Never mind, I'm an idiot. I see now in one of the 1st posts that it needs to be added to index.php
thank,s
jnichols437 replied on at Permalink Reply
My file looks like the following (after the error), but I get this error.

Fatal error: Cannot redeclare json_encode() in /home/content/j/n/i/jnichols437/html/index.php on line 27

What's wrong with the structure of my php? I dropped the json function directly below what already existed in index.php


<?php
require('concrete/dispatcher.php');

function json_encode($a)
{
if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a)) {
$a = addslashes($a);
$a = str_replace("\n", '\n', $a);
$a = str_replace("\r", '\r', $a);
$a = preg_replace('{(</)(script)}i', "$1'+'$2", $a);
return "'$a'";
}
$isList = true;
for ($i=0, reset($a); $i<count($a); $i++, next($a))
if (key($a) !== $i) { $isList = false; break; }
$result = array();
if ($isList) {
foreach ($a as $v) $result[] = json_encode($v);
return '[ ' . join(', ', $result) . ' ]';
} else {
foreach ($a as $k=>$v)
$result[] = json_encode($k) . ': ' . json_encode($v);
return '{ ' . join(', ', $result) . ' }';
}
}
andrew replied on at Permalink Reply
andrew
that's weird, it would seem to imply that you already have a json_encode function.

maybe try wrapping that second function in

<?php
if (!function_exists('json_encode')) {
    ....
}


Although I don't know why the sitemap would load in the first place...

If this doesn't help, do you get any specific errors when you go to

http://www.yoursite.com/index.php/tools/required/dashboard/sitemap_...
jnichols437 replied on at Permalink Reply
I wrapped the 2nd function as suggested. No error, just still no site map. When I hit the URL you suggested, I see this:

[{"cvName":"Home Page","cIcon":"","cAlias":false,"numSubpages":"9","status":"","canWrite":true,"id":"1","selected":false,"subnodes":[{"cvName":"About","cIcon":"","cAlias":false,"numSubpages":"","status":"","canWrite":true,"id":"24","selected":false},{"cvName":"Examples","cIcon":"","cAlias":false,"numSubpages":"7","status":"","canWrite":true,"id":"25","selected":false},{"cvName":"Contact","cIcon":"","cAlias":false,"numSubpages":"","status":"","canWrite":true,"id":"26","selected":false},{"cvName":"Surfing","cIcon":"","cAlias":false,"numSubpages":"2","status":"","canWrite":true,"id":"35","selected":false},{"cvName":"Site Map","cIcon":"","cAlias":false,"numSubpages":"","status":"","canWrite":true,"id":"37","selected":false}]}]
jnichols437 replied on at Permalink Reply
Now I'm getting this error on the run maintenance page.

Fatal error: Cannot redeclare class GenerateSitemap in /home/content/j/n/i/jnichols437/html/concrete/jobs/generate_sitemap.php on line 99
andrew replied on at Permalink Reply
andrew
That's a separate problem. That doesn't actually generate the sitemap in the dashboard - it generates "sitemap.xml" files for use by search engines like Google.

You shouldn't have to run anything to generate your dashboard sitemap. Furthermore, it looks like the JSON data that's being provided to the sitemap is formatted correctly (that's the crap you pasted in the previous post.)
andrew replied on at Permalink Reply
andrew
Hey - sorry if I've missed it in this thread but what browser are you using?
jnichols437 replied on at Permalink Reply
I'm using Firefox. When I try IE, it's another set of problems. Is there a suggested browser for C5?
frz replied on at Permalink Reply
frz
IE7, FF3 on PC.
FF3, Safari on Mac
jnichols437 replied on at Permalink Reply
All right, well you guys are being patient. I've purchased a month of hosting from godaddy just to make sure their ads aren't causing me some issues. I'll report back any changes. Thanks again. I so desperately want to use C5 after looking at and trying Word Press & Joomla. Of course, I have 2 critical things to work out. Inserting links to internal pages (which I need the sitemap working to do) and editing the html.
jnichols437 replied on at Permalink Reply
Two birds with one stone. O.k. so if any other newbie is using free godaddy hosting C5 causes problems with
1) Shen adding a new block and in html mode, there is no update button in the pop-up windows, effectively eliminating the ability to edit/create any html for a content block
2) the site map is not rendered, therefore, you won't be able to create a link to an internal page within a content block.
drdetroit76 replied on at Permalink Reply
What is so special about hosting that might not let the application work?

I currently have my site hosted at webhostfreaks.com and am experiencing some issues with editing the site completely, is there any other way to edit the site or should I ask my hosting provider to add on some items that make it work properly?

Peter
andrew replied on at Permalink Reply
andrew
Free godaddy hosting adds an ad at the top of every page. This is included in the HTTP that's sent to your browser, and it's sent in EVERY request every made.

Well, in the sitemap we're expecting to get data back from the server in a certain format. When that data comes back with a big ad at the top it screws up that data format and the sitemap doesn't render.
nssn replied on at Permalink Reply
I'm having the same issue. Changed my index.php to:

<?php
require('concrete/dispatcher.php');

if (!function_exists('json_encode'))
{

if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a)) {
$a = addslashes($a);
$a = str_replace("\n", '\n', $a);
$a = str_replace("\r", '\r', $a);
$a = preg_replace('{(</)(script)}i', "$1'+'$2", $a);
return "'$a'";
}
$isList = true;
for ($i=0, reset($a); $i<count($a); $i++, next($a))
if (key($a) !== $i) { $isList = false; break; }
$result = array();
if ($isList) {
foreach ($a as $v) $result[] = json_encode($v);
return '[ ' . join(', ', $result) . ' ]';
} else {
foreach ($a as $k=>$v)
$result[] = json_encode($k) . ': ' . json_encode($v);
return '{ ' . join(', ', $result) . ' }';
}
}

but I still get this error when trying to access sitemap:

Unable to load sitemap data. Response received: &title=%26nbsp%3B,{color: #ffffff}&

&x_label_style=10,#ababab,0,2&
&x_axis_steps=1&
&y_legend=Views,12,#333333&
&y_ticks=5,10,5&
&line_dot=3,#4C85BB,,10,5&
&values=0,0,0,3,32&
&x_labels=Mon,Tue,Wed,Thu,Today&
&y_min=0&
&y_max=32&
&bg_colour=#ffffff&
&x_axis_colour=#333333&
&x_grid_colour=#bebebe&
&y_axis_colour=#333333&
&y_grid_colour=#bebebe&
&inner_background=#ffffff,#cccccc,90&
&num_decimals=0&
&is_fixed_num_decimals_forced=1&

Tested in FF3, Opera 9.63, IE7
I'm a total php noob (I chose C5 for ease of use) so I really haven't got a clue.

Please advice
chassa2556 replied on at Permalink Reply
chassa2556
Hi, it looks like the url should bewww.www.mydomainname.com/sitemap.xml... but when I put this in (having in put in the code above) it comes up with an error....am I missing something here...

XML Parsing Error: no element found
Location:http://www.mydomain.co.uk/sitemap.xml...
Line Number 1, Column 1

Usual scant instructions from concrete 5...
creativeorange replied on at Permalink Reply
creativeorange
I had the same problem.

Go into your Control Panel and make sure that your PHP Configuration is set to PHP5 instead of "Automatic" or "PHP4".

I had the same problem and it cleared up right away. Good luck :)
samwestlake replied on at Permalink Reply
Just wanted to let anyone who still has this problem know, that after several successful installations of recent stable versions this seems to have surfaced again in 5.4.1.

My server runs PHP Version 5.1.6 and has several other Concrete 5 instances running without this problem. Fixed by including json_encode() to index.php as described above.

Bit of a head scratcher though ... :o/
Mnkras replied on at Permalink Reply
Mnkras
update your php, 5.1 has many bugs and i believe it has some security flaws,