Comments

earnie’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

I guess not. You need to be more specific with your request. What do you mean by "Entity Type"?

fmizzell’s picture

Sorry, I guess I am an entity guy, I thought Entity Type had a very specific definition. Node, User, Taxonomy Term, Taxonomy Vocabulary and Comment are examples of entity types in core, but anyone can create an entity type for D7. Profile 2, Relation, Commerce, all those module create (or define might be a better word) their own entity types. Some of these entity types have defined ways in which uris are created for their entities, and XML Sitemap should be able to work for those entities that have a uri defined. I hope that is clearer.

earnie’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Most things in Drupal are nodes with specific content types. Those are already all covered. So is taxonomy, user and menu. There is a custom links module to cover the unusual. There is already a request for views and some other content. Adding another feature request for anything that might be content in a general manner will not take place since the unknown cannot be programmed for.

fmizzell’s picture

Status: Closed (won't fix) » Active

@earnie Entity Types are not unknowns, neither is whether they have a path or not. Completely matching the exact functionality that XML Sitemap offers for nodes with any entity could not be possible right now with what core offers, but IMHO XML Sitemap could do a lot better with the information available. Plus there might be other people like me willing to do the work, so if you don't mind I would appreciate if you could leave the issue open just a little bit longer, as I don't believe the request is out of the scope of this module.

earnie’s picture

Status: Active » Postponed (maintainer needs more info)

I can see this as a possible add on module but if it isn't available via core functions then it isn't going to happen for xmlsitemap. The only possible request would be an additional hook to help the add on module and that depends on how much weight the patch brings with regard to processing time.

The major scope of this module is to provide a sitemap.xml rendering of links to nodes in a manner that is fast and efficient for 100's of 1000's of nodes using the core API. If any request has the potential to reduce "fast and efficient" then it will not be considered as part of this module. This module does already provide hooks for you to use.

Can you prove that your concept for a feature will not add processing time or memory use to xmlsitemap?

fmizzell’s picture

That's fair... I will take a closer look at the code and the kind of changes that would be necessary for the add on module to work, and then we can go from there.

Dave Reid’s picture

So yeah, the plan is to eventually have a version that is entity-agnostic since it makes sense. However my experience implementing those types of modules so far in Drupal 7 has proven horribly frustrating (especially with respect to determining which entity types are 'publicly visible' e.g. Pathauto, Meta tags, etc) - #1332058: Need a way to distinguish "public/final" URIs for entities from admin and redirected ones. For example, comment module implements the entity URI callback when it doesn't actually have it's own pages - they just redirect to node pages. Commerce products implement entity URI pointing to the admin URL of the products, not the public-facing URL. So it's a combined matter of frustration with D7 and not being spread too thin between modules.

We're also missing a unified way to alter the 'bundle' forms for entities (e.g. node_type_form, taxonomy_form_vocabulary, etc).

Ideally this rewrite would happen on a 7.x-3.x branch which makes me queasy since 7.x-2.x isn't technically "finished" yet, but it would help clean things up a bit.

kevinquillen’s picture

So there's no way to get an entity like Product or Profile2 into an XML Sitemap???

makangus’s picture

I am trying to figure out how to get some custom entities into XML Sitemap, but I am not sure if I will end up making it general enough for all Entity Type.

makangus’s picture

After writing some code to integrate my custom entity into XML Sitemap, as well as writing a basic module to integrate Profile2 with XML sitemap. I am not sure if it's possible at all at this moment to write something entity-agnostic. I don't even see a simple way to figure out if an entity has an unique ID. I am thinking maybe the better approach, at least for the time being, is to provide a simple hook for modules with custom entities to easily integrate with xmlsitemap. Currently we need to connect to about 8 hooks to get a custom entity into xmlsitemap.

@kevinquillen, here is my first attempt to integrate Profile2 with XML sitemap. http://drupal.org/sandbox/makangus/1783144

bisonbleu’s picture

@makangus, what is the status of your profile2_xmlsitemap project?

That's exactly what I need for a project I'm developing and where users profiles (daycares) need to be added to the xmlsitemap so that they can be indexed by search engines.

makangus’s picture

@bisonbleu, I am not doing much with profile2_xmlsitemap but it does work. You might be able to achieve the same results with the xmlsitemap_user module that comes with xmlsitemap, so I would recommend trying that first. If you do end up using my sandbox module though, feel free to file any bugs.

kevinquillen’s picture

It has to be a case by case basis due to how entities are implemented through EntityAPI - that's what I have found. You could make some workarounds but it is a bit of work.

bisonbleu’s picture

The xmlsitemap_user module is not very useful for my uses case because I use the separate profile page option. User links in xmlsitemap point to user accounts where all you can see is the following.

History

Member for
x month y weeks

kevinquillen’s picture

That's why there's no unified solution, yet.

If you work with the xmlsitemap_profile2 you can adapt it to do what you need.

makangus’s picture

@bisonbleu, you can try my sandbox module and see how that works out for you, but let's move this conversation about profile2 to the issue queue there http://drupal.org/project/issues/1783144.

Let's keep this thread about XMLSitemap for ALL Entity Type.

acbramley’s picture

The apachesolr module does this really nicely and instantly provides any entity type that is set as "indexable" in it's config form. This is sourced from hook_apachesolr_entity_info_alter which is invoked in apachesolr_entity_info_alter and by simply setting $entity_info['my_entity']['indexable'] = TRUE; it is exposed to the index config form.

Could a similar methodology not be implemented for xmlsitemap?

acbramley’s picture

Thanks @makangus for the sandbox, I used it to implement xmlsitemap functionality for my entity type. Copy-paste-find-replace FTW :D

Matthijs’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
FileSize
9.77 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch default-entity-integration-1461670-19.patch. Unable to apply patch. See the log in the details link for more information. View

I've written a patch - using makangus code - to add this feature for all Entity API powered entities.

Please note that an uri and access callback are required. And one of the uri methods must be overridden when entity_class_uri() is used as URI callback.

Matthijs

Status: Needs review » Needs work

The last submitted patch, 19: default-entity-integration-1461670-19.patch, failed testing.

Matthijs’s picture

Status: Needs work » Needs review
FileSize
11.08 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

Fixed "apply patch" issue and some other remaining bugs...

Matthijs’s picture

FileSize
11.14 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

One of the select queries was missing the field to select...

Matthijs’s picture

FileSize
11.14 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

Another quick fix, the bundle should be empty...

tobiberlin’s picture

Hi...

I tried your patch to get my custom entities into xml sitemap but when I generated the sitemap the following the batch was interrupted and the following messages appeared in drupal logs:

Warning: Missing argument 2 for xmlsitemap_entity_xmlsitemap_process_entity_links(), called in sites/all/modules/xmlsitemap/xmlsitemap.generate.inc on line 456 and defined in xmlsitemap_entity_xmlsitemap_process_entity_links() (Line 212 of /sites/all/modules/xmlsitemap/xmlsitemap_entity/xmlsitemap_entity.module).

Notice: Undefined variable: entity_type in xmlsitemap_entity_xmlsitemap_process_entity_links() (Line 213 of /sites/all/modules/xmlsitemap/xmlsitemap_entity/xmlsitemap_entity.module).
	
Notice: Undefined index: controller class in entity_get_controller() (Line 7836 of /includes/common.inc).

Additionally I find no place where I can define the standard xml settings for the entity type. Here you can see the relevant parts of my entity hook info:

      'admin ui' => array(
        'path' => 'admin/path/entity',
        'menu wildcard' => '%entity',
        'file' => 'customentitiy.admin.inc',
      ),
     'xmlsitemap' => TRUE,

Maybe I miss something... on my admin page I just see a list of my entities and the link to add a new entity which is quite the standard I think?!

reallifedigital’s picture

Thanks to @matthijs for the patches!

I found a similar issue mentioned in #24

I didn't get the Missing Argument error, but was unsure how to set the status (inclusion) and priority of each bundle.

I've done some digging.

In my case I'm using ECK, so there is nothing in the patch in #23 which provides a per bundle setting for custom (or ECK) entities- or at least from what I could see.

I got the entities to be included by adding a hook_entity_info_alter() in my custom module like this:

/**
 * Implements hook_entity_info_alter().
 */
function MY_MODULE_entity_info_alter(&$entity_info) {
  $entity_info['product']['xmlsitemap'] = TRUE;
}

(if you're creating own custom entities (not ECK) you should be able to add this to your hook_entity_info())

This allowed for the xmlsitemap inclusion in the xmlsitemap_entity module (as provided in #23), but there was still an additional step required. The main xmlsitemap module looks for the bundle settings (normally set in the admin UI). In xmlsitemap_link_bundle_load() it looks for your custom bundle settings in the variable table, much like it does for node. However, given that there is no UI to set this variable (in the case of ECK entities) I had to add these lines to my settings.php:

$conf['xmlsitemap_settings_product_widget'] = array(
  'status' => '1',
  'priority' => '1.0',
);

...where 'product' is the ECK entity type and 'widget' is the bundle.

Flush caches and everything worked as expected.

Note: I'm not concerned with individual entity priorities, so these steps aren't a complete fix for ECK. I might be able to do this by looking at the way xmlsitemap_entity_form_alter() is hooking into the entity form. The conditions in this function won't match those of ECK's entity forms, so some work would be required there is that's what you need to achieve.

Hope this helps somebody.

osopolar’s picture

FileSize
4.94 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch xmlsitemap-23-26.diff. Unable to apply patch. See the log in the details link for more information. View
14.23 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/xmlsitemap/xmlsitemap_menu/xmlsitemap_menu.module. View

I use this for field-collection-items. It seems to work, but as field-collections don't have an edit bundle form (as for example nodes have), there is no place to set the status and priority settings. It might be done in the field settings, but this is maybe to complicated for a generic approach. I set the variable xmlsitemap_settings_field_collection_item_{field-collection-name} manually (via hook_update_N() implementation in a custom module). Maybe the xmlsitemap_entity module should get it's own admin page?

I haven't got the errors from #23, it's not clear why argument 2 (variable $entity that contains the entity-type) would be missing there. Probably the patch was not applied completely as the $entity variable is used in different places of the same function and it absence would have caused more errors. The patch in #23 adds $entity as second parameter to the 'process callback', the only place where xmlsitemap_entity_xmlsitemap_process_entity_links() gets called in that function.

I was wondering about the function xmlsitemap_link_queue_process() in xmlsitemap.module. There is not second parameter (entity-type) for the 'process callback'. It couldn't be added that easy, as there is another function, xmlsitemap_menu_xmlsitemap_process_menu_links() which receives a second parameter, although it is not set in xmlsitemap_link_queue_process(). Anyway we could not just add $data['type'], which seems to be the entity-type as a second parameter to the callback, as it would get misinterpret in xmlsitemap_menu_xmlsitemap_process_menu_links().

Therefore I changed the second parameter for all xmlsitemap_*_xmlsitemap_process_*_links() callbacks (only the one above mentioned and the new one xmlsitemap_entity_xmlsitemap_process_entity_links() into a data array which may contain different information.

I haven't yet tested the sitemap for xmlsitemap_menu, but I hope the changes won't affect it.

Status: Needs review » Needs work

The last submitted patch, 26: xmlsitemap-entity-integration-1461670-26.patch, failed testing.

The last submitted patch, 26: xmlsitemap-23-26.diff, failed testing.

osopolar’s picture

Status: Needs work » Needs review
FileSize
4.94 KB
14.23 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View
osopolar’s picture

Status: Needs review » Needs work

I get following warning when importing redirects with the Path redirect import module (having the File Entity module installed):

Notice: Undefined property: stdClass::$pid in xmlsitemap_entity_entity_delete() (line 146 of [...]/xmlsitemap/xmlsitemap_entity/xmlsitemap_entity.module).

There entity to be deleted is the (temporary) redirect csv file temporary://redirects.csv.

Would it be okay to test for pid like in the following code snipped?

  if (!empty($info['xmlsitemap']['use entity module']) && isset($entity->pid)) {
    xmlsitemap_link_delete($entity_type, $entity->pid);
  }

This would be fine for the temporary file, as it isn't be part of the sitemap anyway. I am not sure if that is fine in general for all other entities (like other file entities which might be part of the sitemap).

joachim’s picture

Category: Feature request » Bug report

I am getting this error too, when deleting a file.

I don't know what the pid property is meant to be, but files don't have it. It's not something that xmlsitemap sets (there is no other mention of it anywhere in the module's code).

Lots of other entities don't have it either, but 'use entity module' is set on entity types that satisfy fairly general criteria:

    // Check if this type of entity can be indexed.
    $indexable = (isset($info['entity keys']['id']) && isset($info['uri callback']) && isset($info['access callback']));

That's going to be a lot of entity types!

Is pid perhaps a typo?

joachim’s picture

Yup, looking at the signature of xmlsitemap_link_delete(), this is a typo.

The fix is to use entity_extract_ids() to get the ID before calling the function.

osopolar’s picture

Status: Needs work » Needs review
FileSize
14.3 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

Patch changed as suggested in #32:

   if (!empty($info['xmlsitemap']['use entity module'])) {
-    xmlsitemap_link_delete($entity_type, $entity->pid);
+    list($entity_id) = entity_extract_ids($entity_type, $entity);
+    xmlsitemap_link_delete($entity_type, $entity_id);
   }
screon’s picture

Can anyone confirm the latest patch works for custom entities built with ECK?

JeroenT’s picture

+++ b/xmlsitemap_entity/xmlsitemap_entity.api.php
@@ -0,0 +1,27 @@
+ * Describes the hooks provided by the Workflow module.

Workflow should be replaced with XML sitemap entity.

I enabled the module and got the following error:
Warning: Invalid argument supplied for foreach() in element_children() (line 6540 of includes/common.inc).

milos.kroulik’s picture

Would it be possible to add some instruction to the README? The patch applied fine, but I wasn't able to make it work. My custom entities were apparently indexed fine, but not added to the sitemap.