Closed (outdated)
Project:
XML sitemap
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2010 at 05:51 UTC
Updated:
25 Sep 2020 at 14:46 UTC
Jump to comment: Most recent
Comments
Comment #1
dave reidThat's exactly why we have the new xmlsitemap_custom sub-module. :) Enable that module and then go to admin/settings/xmlsitemap/custom
Comment #2
shaundychkoAhhhhh, sorry about the rookie mistake. I had tried the custom module, but mistakenly pasted the entire absolute URL, including the domain, and got the error message: "The custom link [big link with domain] is either invalid or it cannot be accessed by anonymous users.". I doubt many others will make the same mistake, since on second glance it's quite clear what to do, but perhaps, if you have spare time for very minor details, the error checking could look for this mistake since it's quite natural to copy and paste the entire URL.
Thank you very much for rewriting this module. Even with the "unstable" version I've been VERY happy with it, and I'm especially pleased about this custom URL feature.
Comment #3
avpadernoLooking at what done from Drupal core code in http://example.com/admin/settings/site-information, the description for the field reports the URL is relative, even though that should be clean from the text rendered before the textfield (which is the same text rendered in the XML sitemap settings page).
Comment #5
vacilando commentedI need to add custom links to the sitemap, many thousands of them for each website. The way I understand it, /admin/settings/xmlsitemap/custom is not a solution for me, since that allows adding individual links only.
Since the links I need to add are actually produced by views, I briefly thought http://drupal.org/node/507674 was the answer. But that seems to be just a recipe preceding the above custom link adding system.
So I guess need to add them programmatically. I found http://drupal.org/node/264655 which points to http://drupalcontrib.org/api/function/hook_xmlsitemap_links/xmlsitemap
Seems like the answer, but I am not totally clear about the details.
I guess I need to implement hook_xmlsitemap_links() in my module and put in it an array of all the custom links. I am assuming that when xmlsitemap runs (by cron or on manual rebuild process) then this hook is used and the array is incorporated into the sitemap. Correct?
The last thing I am not sure about is what will happen in cases when my array of links will contain 100k links. Will xmlsitemap (cron, rebuild batch) manage such a large array - will it break it into pieces and gradually import or will it choke because of lack of memory? If this is not the way how to add very large sets of links, then how should I do it?
Thanks a lot for any comments!
Comment #6
vacilando commentedFurther to #5 -- I've done a test.
I took a views-produced link http://www.mysite.tld/path/abc123 and added the following code in my module called 'mymodule':
But after rebuilding the URL http://www.mysite.tld/path/abc123 is not in the sitemap. Looked for xmlsitemap errors in /admin/reports/dblog but there was just one message saying the rebuild had completed successfully.
What am I doing wrong?
Also, how to submit 100k links like this - the same way? (See #5.)
Comment #7
vacilando commentedOne month later... did a number of tests in beta1 and in dev in the meantime but the above code (#6) never includes my views links in the sitemap. Could somebody please advise what's the correct method for adding such links programmatically?
Comment #8
shaundychkoI think this comment: http://drupal.org/node/499670#comment-1761566
combined with this module (currently in dev): http://drupal.org/project/views_build_menu
could provide a clean solution for this issue, but in the meantime, for the bold (and careless?) hackers, here's a solution that sort of works for my specific scenario. I want to include nodes that are returned by a view. The content type must be excluded from the xmlsitemap by default, so the following is to avoid clicking on the sitemap include option on each node edit page.
Using http://drupal.org/project/views_bonus I exported a list of node id's in csv format. Using phpmyadmin, import this into a new table (called get_these in this example) which has a column of type integer (called nid). With the xmlsitemap table selected, choose the SQL tab, and paste the following code:
UPDATE xmlsitemap,get_these SET xmlsitemap.status='1',xmlsitemap.status_override='1'
WHERE xmlsitemap.id=get_these.nid
This works only if the content type was previously included by default, with a subsequent cron run in order to put them into the xmlsitemap table, and then disabled, followed by cron, which, instead of deleting them from the table, sets the status and status_override values to 0. Furthermore, after running the SQL above successfully, the sitemap needs to be rebuilt at /admin/settings/xmlsitemap/rebuild since a mere cron run will not pick up the new entries.
I can't wait for a better way of doing this! =)
Comment #9
shaundychkoAs another approach, I've tried creating a module that uses the xmlsitemap_custom module, and views. It works until it encounters a form validation error (such as when a node already exists in the sitemap). Would someone care to help solving this issue? I think the module should work if drupal_execute() could keep processing beyond when it encounters the validation error. The dpm() in here shows that the code loops through all nodes returned by the view, but drupal_execute() doesn't process after an error.
xml_views.info:
xml_views.module:
Comment #10
vacilando commentedFinally got #6 to work.
Very briefly, my 2 cents worth:
1) Instead of making an array of arrays, each array simply needs to be saved using xmlsitemap_link_save($singlelinkarray)
2) Also, you need to call hook_xmlsitemap_links() in your hook_cron()
Cron then adds links to the xmlsitemap table.
By running a rebuild the actual sitemap files are then created on from that table.
It works for me -- at least before someone suggests a better approach.
Enjoy!
Comment #11
samuelet commented#10 works also for me, thanks Vacilando.
About this workaround, i'm pretty sure that the sitemap "Maximum number of sitemap links to process at once:" setting is not automatically applied in this approach, so that you have to take care yourself of such implementation in case you have an high amount of links to add.
Comment #12
rag_gupta commentedWe can as well generate custom links(like from Views arguments: /category/jobs/%) using a php module/script and generate a simple txt file which we can submit to Google/Bing. Any special advantage in adding such bulk links using XML Sitemap module?
Comment #13
avpadernoI am closing this issue, which is for a not supported Drupal version.