Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I guess the title says it all
Comment | File | Size | Author |
---|---|---|---|
#64 | xmlsitemap-add-files-to-sitemap-1461670-64.patch | 16.92 KB | Jelle_S |
#52 | xmlsitemap-add-files-to-sitemap-1461670-52.patch | 16.45 KB | Jelle_S |
| |||
#47 | xmlsitemap-add-files-to-sitemap-1461670-47.patch | 13.31 KB | wildfeed |
|
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI guess not. You need to be more specific with your request. What do you mean by "Entity Type"?
Comment #2
fmizzell CreditAttribution: fmizzell commentedSorry, 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.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedMost 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.
Comment #4
fmizzell CreditAttribution: fmizzell commented@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.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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?
Comment #6
fmizzell CreditAttribution: fmizzell commentedThat'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.
Comment #7
Dave ReidSo 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.
Comment #8
kevinquillen CreditAttribution: kevinquillen commentedSo there's no way to get an entity like Product or Profile2 into an XML Sitemap???
Comment #9
makangus CreditAttribution: makangus commentedI 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.
Comment #10
makangus CreditAttribution: makangus commentedAfter 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
Comment #11
bisonbleu CreditAttribution: bisonbleu commented@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.
Comment #12
makangus CreditAttribution: makangus commented@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.
Comment #13
kevinquillen CreditAttribution: kevinquillen commentedIt 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.
Comment #14
bisonbleu CreditAttribution: bisonbleu commentedThe 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.
Comment #15
kevinquillen CreditAttribution: kevinquillen commentedThat's why there's no unified solution, yet.
If you work with the xmlsitemap_profile2 you can adapt it to do what you need.
Comment #16
makangus CreditAttribution: makangus commented@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.
Comment #17
acbramley CreditAttribution: acbramley commentedThe 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?
Comment #18
acbramley CreditAttribution: acbramley commentedThanks @makangus for the sandbox, I used it to implement xmlsitemap functionality for my entity type. Copy-paste-find-replace FTW :D
Comment #19
MatthijsI'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
Comment #21
MatthijsFixed "apply patch" issue and some other remaining bugs...
Comment #22
MatthijsOne of the select queries was missing the field to select...
Comment #23
MatthijsAnother quick fix, the bundle should be empty...
Comment #24
tobiberlinHi...
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:
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:
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?!
Comment #25
Barry_Fisher CreditAttribution: Barry_Fisher commentedThanks 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:(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:
...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.
Comment #26
osopolarI 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 wherexmlsitemap_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.
Comment #29
osopolarComment #30
osopolarI get following warning when importing redirects with the Path redirect import module (having the File Entity module installed):
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?
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).
Comment #31
joachim CreditAttribution: joachim commentedI 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:
That's going to be a lot of entity types!
Is pid perhaps a typo?
Comment #32
joachim CreditAttribution: joachim commentedYup, 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.
Comment #33
osopolarPatch changed as suggested in #32:
Comment #34
screon CreditAttribution: screon commentedCan anyone confirm the latest patch works for custom entities built with ECK?
Comment #35
JeroenTWorkflow 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).
Comment #36
milos.kroulik CreditAttribution: milos.kroulik commentedWould 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.
Comment #37
jmdorian CreditAttribution: jmdorian commented@milos.kroulik
I've added some code to my module in form_alter hook (you can use specific, I've added to general):
This code adds a fields to a form and submit function, that's why you don't need do nothing else to get it works.
Comment #38
nicola85 CreditAttribution: nicola85 commentedComment #40
nicola85 CreditAttribution: nicola85 commentedComment #41
nicola85 CreditAttribution: nicola85 commentedComment #42
ggmacasaet CreditAttribution: ggmacasaet commentedNeed some help on this since i've already patched the codes that we have here but the custom entity that i have is still not yet visible. I already have it indexed and available but its not going to VISIBLE thus not showing on the XML sitemap.
Comment #43
wildfeed CreditAttribution: wildfeed as a volunteer commentedPatch in #41 worked well but did not support adding files to the sitemap. In this patch I added add a form element to the file-type edit form. By editing a file-type and setting the "Inclusion" item to "Include" files are added to sitemap.xml when cron runs.
Comment #44
wildfeed CreditAttribution: wildfeed as a volunteer commentedRe rolled the patch in #43 - which was based on the patch in #41. This updated code adds a new module, xmlsitemap_file which supports adding files to the sitemap. The module also appends "/download" to the file path before adding the link to sitemap.xml - this way a crawler can actually access the contents of a .pdf file.
Comment #45
wildfeed CreditAttribution: wildfeed as a volunteer commentedThis patch adds a module to the patch in #41. It adds support for adding files to sitemap.xml and allows for "/download" to be added to url so a text file can be displayed in the browser and indexed.
Comment #46
brockfanning CreditAttribution: brockfanning commentedComment #47
wildfeed CreditAttribution: wildfeed as a volunteer commentedThis patch adds a module (xmlsitemap_file) to the patch in #41.
XML sitemap file supports adding files to sitemap.xml and allows for "/download" to be added to link url (optional) so a text file can be displayed in the browser and indexed.
XML sitemap file passes "timestamp" as "changed property" so $entity->timestamp is used for "Last modification date"
patch fixes issue in comment #35 - replaces reference to "Workflow module" with "XML sitemap entity module"
Please review
Comment #48
brockfanning CreditAttribution: brockfanning commentedThis update adds the per-entity override form to file entities, so files can be individually included/excluded. It also adds some code that seems to be needed in order for the entity edit form to remember the overrides for an entity. Interdiff attached.
General notes: The xmlsitemap_file module added in recent patches seems like a good example of leveraging the xmlsitemap_entity module for integration with another contrib module. I notice that ECK (entity construction kit) needs a bit of help as well, in getting the various form elements added. Maybe a similar module (xmlsitemap_eck?) could be added in this patch? Field Collection is mentioned above also, so might be another candidate for a module.
It could be argued that these contrib integrations should be in separate patches, and that only the xmlsitemap_entity module should be added here. I would support that, except that it's not clear what the xmlsitemap_entity module should do by itself. If it's only an "API module", then that should be made clear, and maybe an example implementation provided (like the xmlsitemap_file from recent patches).
Comment #49
Jelle_SLooking at the interdiff from #41 to #47 (in comment #47) the second argument to the process callback (
array('entity_type' => $entity)
) was removed again, which causes it to fail indexing for me. Subsequent patch in #48 doesn't seem to fix that.Also, xmlsitemap_entity_query_alter() contains a fix for EntityFieldQueries for users (because of #1054168: EntityFieldQuery fails for entities that have no bundle). As long as #1054168: EntityFieldQuery fails for entities that have no bundle is not fixed, maybe we should add a fix for entities without bundles in general?
Comment #50
brockfanning CreditAttribution: brockfanning commentedThanks for pointing that out @Jelle_S about the argument issue - I'm getting the same thing. Here's an attempt to add that code back in.
Your idea about entities without bundles seems reasonable to me. I don't have time at the moment to try implementing that, but it does seem like something that should be done in this issue.
Comment #51
Jelle_SMy stab at it.
Comment #52
Jelle_SRerolled against latest dev.
Comment #53
ThuleNB CreditAttribution: ThuleNB commentedI installed the latest dev version and recognized some problems:
Running cron, deleting cache and rebuilding sitemaps do not resolve this.
Comment #54
brockfanning CreditAttribution: brockfanning commentedRegarding the file entity integration: After further testing in production I believe that a change I added to this patch in #48 was probably unnecessary. Instead a simpler form alteration is need for a specific use-case involving some common file-related modules (file_entity, media, media_bulk_upload, and multiform). So in the interests of keeping unnecessary stuff out of the patch, here is an update to make those changes.
In regards to the review by @ThuleNB: This is great feedback. It sounds like this patch does NOT provide complete integration with field_collection entities. Getting feedback like this on a variety of entity types will probably be needed to truly "generalize" this module.
@ThuleNB: I don't have much experience using field collections as stand-alone entities -- they do get their own URLs? I always thought field collections were purely for attaching to other entities, but sounds like I'm mistaken there?
General note: Obviously also, this patch is really in need of some tests.
Comment #55
Jelle_S@brockfanning: That is the way I understood as wel, but from the Field Collection project page:
So yes, they do get their own urls.
See also field_collection_field_get_path() and FieldCollectionItemEntity::defaultUri().
Comment #56
brockfanning CreditAttribution: brockfanning commented@Jelle_S: A minor tweak to the entity query alter, to avoid a PHP warning that happens in my Drupal install.
Comment #57
brockfanning CreditAttribution: brockfanning commentedArg, fixing a typo.
Comment #58
Jelle_SHm, weird, seems like
entityConditions
should never be a string... See https://api.drupal.org/api/drupal/includes%21entity.inc/function/EntityF...Wich means we should not only check the value, but also the operator...
Which got me thinking. Maybe we shouldn't be fixing this here... It seems this is in place to fix the uses of EntityFieldQuery in xmlsitemap itself. Maybe we should fix it there (used in xmlsitemap.drush.inc, xmlsitemap.generate.inc, xmlsitemap.module). We could just do the same check there before adding the bundle condition. Maybe that's something to fix in a different patch though? Since a similar hook is already in place for the user entity.
Comment #59
Jelle_SComment #60
brockfanning CreditAttribution: brockfanning commented@Jelle_S: Yes I think I'm leaning that way too. Probably the best this patch can do is to lay the (potentially incomplete) groundwork for support of other entity types, and then maybe to include complete support for some common/popular entity types (like the currently included xmlsitemap_file). If that entity query alter is mainly for support of user entities, then it may belong in an "xmlsitemap_user" submodule?
Comment #61
Jelle_SWell it's for bundle-less entity types, of which user is a core example. But we can't special case it for user since https://www.drupal.org/project/user_bundle exists. That is why I created the patch over at #3011651: Fix EntityFieldQuery uses. It checks the entity info to see if the entity type we're querying for has bundles. It's a generic approach that should work for all entities (even when they're altered like User Bundle does). That patch also removes the hardcoded special case for user entities.
Comment #62
Jelle_SDid some code cleanup (trailing spaces, comment punctuation, code extraction to a separate function, and some early returns to limit if-nesting). If or when #3011651: Fix EntityFieldQuery uses get committed we can remove
xmlsitemap_entity_entity_query_alter()
.Comment #63
Jelle_SFixed some copy paste errors.
Comment #64
Jelle_SPatch contained changes from the other issue...