Is there a proper possibilty to add urls of view sites to the generated sitemap? I switched from drupal 5 to 6, using the powerful views module now. The views I use change not very often, so it would be great to have them in the sitemap. Are there plans to write something like a xmlsitemap_views module?
By the way, view urls are also not included when using the xmlsitemap_menu module and having them as primary links.

The hack I use is to manually type them into the custom module - not very elegant nor flexible.

Comments

dave reid’s picture

There aren't any plans at the moment to have a views-only submodule since there are the two ways that you have already described here. If you added the view to your primary links, you'd probably have to make sure that cron runs at least once afterwards for the change to be picked up. Also, you have to make sure that your view is accessible to anonymous users as well. Otherwise the link to the view is not going to be included in the sitemap.

avpaderno’s picture

The hack I use is to manually type them into the custom module - not very elegant nor flexible.

As the URL associated with a view doesn't normally change (if the URL is not using "%" replacements), I would think that using xmlsitemap_custom.module is enough; the few times you change the view URL, you can also change the URL reported to XML sitemap custom.

DrupalKing’s picture

Views generated pages need to be included because it's absurd that by default they wouldn't be included in the sitemap. I don't know about you all, but my Views pages are a major part of my site. Having to add them manually with the custom module is additional work I shouldn't have to do.

dwightaspinwall’s picture

Then perhaps you should contribute a module to do just that. ;-)

dave reid’s picture

One of the major problems with adding an xmlsitemap_views submodule is that a lot of views have arguments (Taxonomy views) there's not a good way to do something like get-all-possible-paths-for-this-view. If there was, writing that kind of module would be a little easier. The easiest way to do so is to create a menu at admin/build/menus called "xmlsitemap" and in your Views editing, add the view to the menu. Then, make sure you have the xmlsitemap_menu module enabled and make sure that the xmlsitemap menu is included in the sitemap.

avpaderno’s picture

I agree with Dave; it's not possible to handle views in a specific way. Even the approach followed by Meta tags is not correct, as it's not able to handle all the displays used by a view.

dave reid’s picture

Title: Views » Sub-module for views
Status: Active » Postponed

Marking as postponed for now.

vacilando’s picture

Much interested - even if only for specific kind of views.

YK85’s picture

subscribing

xxparanormalxx’s picture

subscribing

tigron’s picture

Subscribing

Andrew Gorokhovets’s picture

Subscribing

manoloka’s picture

subscribing

manoloka’s picture

The easiest way to do so is to create a menu at admin/build/menus called "xmlsitemap" and in your Views editing, add the view to the menu. Then, make sure you have the xmlsitemap_menu module enabled and make sure that the xmlsitemap menu is included in the sitemap.

but views won't let you add a menu if the path has a argument %

???

treksler’s picture

there's not a good way to do something like get-all-possible-paths-for-this-view.

Isn't this the definition of a site map? "Get all possible paths" OK, so there's no good way to do it. Well, then that's a design flaw with views or XML site map and it should be fixed/redesigned so that a site map is possible.

Anonymous’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev

While this request is being contemplated, there is the xmlsitemap_custom module you can use to add URL that xmlsitemap doesn't automatically get. The custom module exists just for this reason.

sgdavis’s picture

What about adding an option where the user can at least specify what type of an argument should be provided? For example, most of my views all take the argument of a Node ID so you could query the node table for all available node IDs. Even if you just queried for the largest and went from 1-max, I would imagine most Views wouldn't fail as usually they are designed to operate with some fallback argument. I could imagine supplying a minimal number of possibilities would at least be a great start. I.e., node ID, user ID, date, custom specified list (could be user supplied in a textbox, one item per line), etc.

Anyway, I would be very interested in this as it is incredibly annoying to have to add a menu item or custom xml sitemap entry every time that I add a node.

Anonymous’s picture

Re: #17

Are the node and view links both available to the anonymous user? Having the same content presented with differing URLs is a big SEO no no.

aheredia’s picture

Status: Postponed » Needs review

I've some views with arguments of type %. I've made a first approach trying to include the dynamics urls of the view into the sitemap.
The idea is include the url when the user visit the view page using the arguments of the view using the hook_page_alter(&$page). Here is the initial code:

  $view = views_get_page_view();
  if (!empty($view)) {
    $link = array (
      'id' => db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")->fetchField() + 1, 
      'loc' => current_path(), 
      'priority' => XMLSITEMAP_PRIORITY_DEFAULT, 
      'lastmod' => 0, 
      'changefreq' => 0, 
      'changecount' => 0, 
      'language' => LANGUAGE_NONE,
      'type' => 'custom',
      
    );
    xmlsitemap_link_save($link);
  }

Seems to work

Anonymous’s picture

Status: Needs review » Postponed

There is no patch file so nothing to review.

You shouldn't be setting the id, it is auto incremented on the save.

aheredia’s picture

You shouldn't be setting the id, it is auto incremented on the save.
The id field is not an autoincremental field. The primary key of the table is composed by id and type field so i thought i should increment the id by code.

I've made same changes to code to control the path doesn't exist on the table yet.

 $view = views_get_page_view();
  if (!empty($view)) {
    // Check if path exists
    $id = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = 'custom' and loc = :loc", array(':loc' => current_path()))->fetchField();
    if (!$id) {
      $id = db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")->fetchField() + 1;
      $link = array (
        'id' => $id,
        'loc' => current_path(), 
        'priority' => XMLSITEMAP_PRIORITY_DEFAULT, 
        'lastmod' => 0, 
        'changefreq' => 0, 
        'changecount' => 0, 
        'language' => LANGUAGE_NONE,
        'type' => 'custom',
      
      );
      xmlsitemap_link_save($link);
    }
  }  
Anonymous’s picture

Shows what happens when you guess at how it is implemented, sorry for the miss instruction.

Now you need to provide a proper patch. See http://drupal.org/node/707484 if you need guidance on doing that.

aheredia’s picture

What would be a better approach?
Create a independent Submodule.
Or
Insert code in existing one, xmlsitemap_custom for example.

Anonymous’s picture

Assigned: Unassigned » dave reid

Since the views module will be delivered as part of core in D8 I think your change makes sense in xmlsitemap_node. Otherwise it will be another module named xmlsitemap_views but is it worth that? Dave Reid, what is your advise on this question?