eZ Community » Forums » Developer » site map xml with language listing in...
expandshrink

site map xml with language listing in main site

site map xml with language listing in main site

Saturday 05 November 2011 1:02:08 pm - 13 replies

Hello All,

I need to create an xml sitemap in language site .. i have created it but my site is multilanguage and i am able to check my xml sitemap under each language site access by using url as : http://mysite.com/sitemap.xm l and http://mycist.com/es/sitemap.xml what i need to have us the listing of spanish sitemap.xml in main site also i.e http://mysite.com/sitemap.xml will contain both links eng as well as spanish .. i have tried to fetch language specific url but i am not able to do it can any one suggest me what i should try to get this done .

Thank you very much for your time,

Akhi

Saturday 05 November 2011 7:30:01 pm

Hello Akhilesh,

I have used this tool [0] to create muliple sitemaps for different siteacesses dynamically on a set schedule via cron. I really like using this tool for this task, I hope you will too.

[0] http://projects.ez.no/all2egooglesitemaps

I hope this helps ...

Cheers,

Heath

Tuesday 08 November 2011 1:02:16 pm

Hi Health,

could you kindly guide me through this implementation? I've tried to do on my own but all I have done is just replace the first part of url...and this is not correct

my wrong example:

ITA version
www.site.com/index.php/ita/Chitarra

ENG version
www.site.com/index.php/eng/Chitarra

instead I should have
www.site.com/index.php/eng/Guitar 

("Chitarra" is the italian translation for "Guitar"blunk.gif Emoticon

Thanks in advance!

Luca

Tuesday 08 November 2011 3:21:12 pm

Hello Luca,

You will want to follow the installation instructions within the extension source code,

http://svn.projects.ez.no/all2egooglesitemaps/trunk/all2egooglesitemaps/doc/installation.txt

If you read this you will see you can create sitemap xml files only by the following convention.

The extension when properly installed will generate the required sitemap xml files.

This extension generates sitemap files in this url format, http://example.com/sitemap_eng-GB.xml

If you read the cronjob php code you can see that the sitemap file name is determined by a few key factors,

$sitemapName = $googlesitemapsINI->variable( 'all2eGoogleSitemapSettings','Filename' );
$sitemapSuffix = $googlesitemapsINI->variable( 'all2eGoogleSitemapSettings','Filesuffix' );
$sitemapPath = $googlesitemapsINI->variable( 'all2eGoogleSitemapSettings','Path' );
// snip, skipping other code not related to example
// write XML Sitemap to file
$xmlDataFile = $sitemapPath.$sitemapName.'_'.$language['siteaccess'].$sitemapSuffix;
$dom->save($xmlDataFile);

This may mean you want to create an apache mod_rewrite to point your desired url name (translated) to your generated xml file. Or alternatively you could edit the php code to generate the file name based on other factors (not recommended)

I hope this helps ...

Cheers,

Heath

Modified on Tuesday 08 November 2011 3:27:33 pm by Heath Heath

Tuesday 08 November 2011 3:25:35 pm

Hi Health,

I tried using all2egooglesitemaps but it does not includes my language site links in xml generated ..

So can you please help me in merging english as well as spanish site map XML in main site xml i.e english.

 

Thank you for you time,

Akhi

Tuesday 08 November 2011 3:30:39 pm

Hello Akhilesh,

I do not believe what you describe is supported through this extension. By default the contents of the two siteaccess based sitemap files would be different. You would have to change the cronjob PHP to achive a combined sitemap xml file.

Also what do you mean by "it does not includes my language site links in xml generated"? This is not clear ....

 

I hope this helps ....

Cheers,

Heath

Tuesday 08 November 2011 3:36:53 pm

Hi Health,

I have an older version without this feature!!! I will try your solution! Thanks!

....UPDATE....

Your solution works like a charm! happy.gif Emoticon THX!

Modified on Tuesday 08 November 2011 3:51:52 pm by Luca Mischiatti

Wednesday 09 November 2011 6:31:39 am

Hi Health,

By the line "it does not includes my language site links in xml generated" 

i meant that it includes english i.e non translated link in sitemap.xml

http://mysite.com/Meetings/Meeting-RFP but what i need is that it should also include its translation link in it also i.e both english and spanish like below.

http://mysite.com/Meetings/Meeting-RFP
http://mysite.com/es/Reuniones/Reunión-RFP .. the code i have used previously to get sitemap.xml for my sites is as below :

 <?xml version="1.0" encoding="UTF-8"?>  {def $pages = fetch('content','list',hash('parent_node_id',2,'sort_by',array('priority',true),'depth',4,'class_filter_type','include','class_filter_array',array('sub_page', 'home_page', 'sub_page_container')))}<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>{""|ezurl("no","full")}</loc> <priority>1.0</priority> </url>{foreach $pages as $page}{if eq($page.is_hidden,0))} <url> <loc>{if eq($page.class_identifier,'file')}{$page.data_map.file.content.filepath|ezurl("no","full")}{else}{$page.url_alias|ezurl("no","full")}{/if}</loc> <priority>0.5</priority> </url>{/if}{/foreach}
</urlset>

what i was believing is that creating one more fetch which will fetch language translated nodes will accomplish my requirement but that doesn't happened for me ..sad.gif Emoticon so can you help me in this how can i get both translated and non translated links in single sitemap.xml..

 

Thank you very much,

Akhi

Wednesday 09 November 2011 7:11:32 am

Hello Akhilesh,

This is because by default (to my knowlege) content is fetched by default using the language of the current siteaccess (whether in the PHP context or the template context).

I think you would grow in knowledge by re-reading the content/list fetch function documentation.

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list

 

Specifically the parts about 'only_translated' (like the comments on the doc and issue) which seem to indicate that at least that feature is long ago deprecated and removed. So you don't want to try to use that parameter.

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list/only_translated-deprecated

http://issues.ez.no/13321

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list#eztoc87605_0_0_8

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list#eztoc87606_0_0_18

But it seems (at least by the content/list fetch function docs) that you can use the language parameter to fetch content by each of your content locales. So In theory you would fetch the content one time for each locale used in your content tree / used by your siteaccess.

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list#eztoc87606_0_0_19

 

The above rules also apply to the PHP eZContentObject API,

https://github.com/ezsystems/ezpublish/blob/master/kernel/classes/ezcontentobject.php#L1023

 

So depending how you prefer to fetch the data, you should be able to do so using these call parameters.

If I was to do this (regardless of which in point you use) I would fetch as needed, storing the array of result content from each fetch (in each local) into an array and then iterate over that list to build your sitemap etc. This should give the desired result.

 

I hope this helps ...

 

Cheers,

Heath

Wednesday 09 November 2011 7:43:05 am

Though as I think about this a little more I realize that it would prolly be best to modify the extension I shared above to perform this task.

Specifically just a small part of this file, http://svn.projects.ez.no/all2egooglesitemaps/trunk/all2egooglesitemaps/cronjobs/generate.php

 

I don't know if this helps you but ... I took a few minutes to re-write a copy of the above cronjob part (php script) to generate the content as I described above and write all the content into one sitemap file (without the language in the filename as that no longer applies). The rest of the script functions as it did before. I'm afraid while I had time to write this code, I did not have time to test it or run it myself.

Still forgoing anything I missed in my haste it should generate a single sitemap with content content in every language used in individual siteaccess settings (you must have a siteaccess configured for each language, possible limitation in some configurations) as you need.

 

Update: We have moved this solution from some random pastebin site to GitHub for long term hosting, maintenance and support. In the process we heavily commented the solution and made a few useful improvements, get a yourself an updated copy today, https://gist.github.com/1387897

 

I hope this helps ...

 

Cheers,

Heath

Modified on Wednesday 23 November 2011 5:34:09 am by Heath Heath

Tuesday 28 February 2012 4:22:04 pm

Hello,

I installed the all2egooglesitemaps but it only generates sitemap for the main language. How can I make it generate for the other languages?

 

Thank you

Saturday 31 March 2012 12:34:55 pm

Hello eZ Community!

 

We have recently created a friendly fork of the all2egooglesitemaps extension on GitHub which replaces the previously described Gist above.

https://github.com/brookinsconsulting/all2egooglesitemaps

 

Our modified extension now provides the above described multilingual cronjob part within the all2egooglesitemaps extension and an expanded documentation section.

 

So now you can simply use this fresh new extension cronjob part to create multilingual sitemap xml content with ease right out of the box (no integration required).

 

We hope this helps ...

 

Cheers,

Heath

Modified on Saturday 31 March 2012 12:35:22 pm by Heath Heath

Tuesday 03 April 2012 4:54:07 pm

Hi guys,

[open discussion]

concerning sitemap xml, could you point me why it would be useful to generate it and write it on the disk ? I mean, this file is not read very often by Google so we don't really need it to be a static resource, right ? That said, it might be more easy to "generate" the xml via a dedicated module + a rewrite rule or an virtual url pointing to that module.

Cheers,

Arnaud

Wednesday 04 April 2012 3:54:10 pm

Hello Arnaud,

For some sites, the sitemap does not change very often, nor does it need to be updated often. In those cases a static sitemap does the job just fine.

But your right some sites need a more dynamic solution, I've seen two other such implementations one using the layout/set module view and another custom module view on projects.ez.no

I had had thoughts of combining the ideas of the other two extensions into the all2egooglesitemap extension for ease of use.

What do you think?

Cheers,

Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu