Jump to content

MarkupSitemap


Mike Rockett

Recommended Posts

  • 1 month later...

What do you think about making the module extensible via hooks?

I had a client request a sitemap that included videos. Now, methods of storing videos differ: file fields, video URLs, embed codes, and so on. I suspect there's no straightforward way to include videos in the sitemap using just this module.

However, implementing this on a site-by-site basis would become simple if there was a way to hook into the sitemap creation process and append different definitions like video or news item yourself.

Of course, I could create the whole sitemap from scratch — but your module does a lot of things very well and I'd love to build upon that.

Link to comment
Share on other sites

  • 1 month later...

Thanx for your module - MarkupSitemap, v. 0.4.1. Works perfect (PW 3.0.123)!
What about adding 'x-default', a reserved hreflang attribute, when no languages match? recommended by Google & Yandex.

 "Use the x-default tag for unmatched languages. The reserved value hreflang="x-default" is used when no other language/region matches the user's browser setting.
This value is optional, but recommended, as a way for you to control the page when no languages match."
,
google.com/webmasters/answer/189077#sitemap | webmasters.googleblog.com/.../x-default-hreflang-for-international-pages.html

<xhtml:link rel="alternate" hreflang="x-default" href="...URI-to-default-language..." />

Something like this:

hreflang-x-default.png.990282f0039da0baa083a1cb7fe86841.png

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

Hey @Mike Rockett,

Any chance you could add this module to Packagist?

Would love to use it on my current project, but I'm relying on Composer. Would be nice not to have to install this module via Git or add the repository manually to composer.json. It would also be awesome if you could declare type as pw-module and add wireframe-framework/processwire-composer-installer as a dependency for easy installing.

Thanks for considering! ??

  • Like 4
Link to comment
Share on other sites

  • 3 weeks later...

Hey @teppo - sorry for the delayed reply here. This can definitely be done. Good work with the composer installer - haven't been around for a while now, so didn't see it pop up. ?

Hey @Lance O. - You're very welcome - glad you like the module! ? I don't think your issue is related to the URL validator, as the filter does say that URL is valid, as expected. This leads me to think that it's a spelling issue with the field name, though that seems unlikely. Would you mind doing a little debugging and checking to see if the URL does indeed get knocked out at https://gitlab.com/rockettpw/seo/markup-sitemap/blob/master/MarkupSitemap.module.php#L447?

  • Like 1
Link to comment
Share on other sites

@Mike Rockett

Sure, let me know exactly what you need me to do. Here is the field settings as copied from phpMyAdmin, in case there is something incorrect there:

{"description":"The Open Graph Image is used when sharing the page to social media services like Facebook and Twitter. Upload images that are **1200 x 630 pixels** for the best display on high resolution devices. At minimum, use images that are **600 x 315 pixels**. Be sure to include a description to be used as the alt tag.","textformatters":["TextformatterEntities","TextformatterStripTags"],"extensions":"jpg jpeg png","maxFiles":1,"outputFormat":0,"defaultValuePage":0,"useTags":0,"inputfieldClass":"InputfieldImage","collapsed":2,"descriptionRows":1,"gridMode":"list","focusMode":"on","resizeServer":0,"clientQuality":90,"overwrite":1,"maxWidth":1200,"minWidth":600,"minHeight":315,"tags":"meta images","icon":"tag","fileSchema":6,"otherField":"License","otherFieldSettings":"{\"cf_textformatter\":{\"license\":\"\"},\"cf_label\":{\"cf_label__license\":\"\"}}"}

Link to comment
Share on other sites

@Lance O.

Looks like it could well be a case sensitivity issue with the license field, where yours is using an upper case "L", it is actually expecting it in lowercase. Are you able to rename the field and try again? Whether or not that fixes it, I'll need to push an update that converts the casing appropriately.

Link to comment
Share on other sites

  • 1 month later...

Hi @Mike Rockett – I'm back with the endless requests ?

How do you feel about supporting WireCache in MarkupSitemap, possibly as an alternative to (if not instead) MarkupCache? The thing is that due to hosting-related reasons caching in the database would be easier for me, while current MarkupCache implementation is slightly problematic.

I could send you a PR (or merge request, as you're using GitLab) in case you're interested.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Sorry @Mike Rockett – got caught up with other stuff (surprise) and forgot about this ?

I've just sent a merge request for WireCache support. It's an alternative to existing MarkupCache cache method, configurable via module settings. I've also made cache TTL (expire time) configurable: https://gitlab.com/rockettpw/seo/markup-sitemap/merge_requests/1.

Let me know what you think ?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hey @Mike Rockett!

I'm wondering if there's some way to add support for URL segments in the module. Any chance you might've figured this out already? ?

Basically in my use case there are pages that list items below them, yet those items actually live outside of the publicly viewable page tree. It's a no-brainer that they wont work right out of the box, but what I'm wondering is if we could somehow – hook or some template setting or something – inform MarkupSitemap of these "non-pages", and add them to the sitemap.

I had a quick look at the codebase, and I'm wondering if this could be achieved by an optional hook in MarkupSitemap::addPages, perhaps by passing $page and $url to a hookable method after calling $this->urlSet->addUrl($url)? Seems that this way I could add a custom round of iteration and also add those URL segments as new URLs to the URL set ?

  • Like 3
Link to comment
Share on other sites

Another related feature that I've thought about often is a hook for adding custom resources. The main use case would probably be videos tied to specific pages. As there is no agreed-upon way of uploading videos in ProcessWire, the module can't know what is a video and what isn't. Hooks would be perfect here.

Link to comment
Share on other sites

Hey @teppo and @d'Hinnisdaël – both very good ideas indeed. I'm happy to implement both hooks, the only problem is that this time of year is super busy for me, so I won't be able to get to it straight away. If it's something you're looking for in the immediate-term, please feel free to pop me a merge request or two. In the meantime, I'll open up an issue on the repo. ?

  • Like 2
Link to comment
Share on other sites

@Mike Rockett @teppo I just stumbled upon a local fork to the module I made some time ago that adds that functionality (additional URLs per page, added via a hook). I'll whip it into shape and create a merge request in case that provides useful or as a starting point. It's working quite well locally, just have to fork from the current state and add some docblocks.

  • Like 1
Link to comment
Share on other sites

@Mike Rockett @teppo I created a merge request on GitLab. Happy to get some input on that. It includes an example implementation and an updated readme section on dynamic URL segments.

One thing that I couldn't figure out is creating alternate-language URLs inside the hook. The LanguagePageNames module doesn't create the hooks for Page->localHttpUrl() if the requested page results in a 404 error (which it always does when generating the Sitemap since that's what triggers it). That's why the Sitemap module manually adds those hooks when initializing. However, even when the module has been initialized and the hooks should have been added by that point, localHttpUrl() is not available on any Page object inside the hook.

I worked around that in my previous project by doing the same as the Sitemap module and adding the localUrl methods manually. It's however far from an ideal solution to have to add all that boilerplate.

Any ideas?

wire()->addHookAfter('MarkupSitemap::getAdditionalPageUrls', function ($event) {
    /* get arguments */

    static $hooksAdded = false;
    if (!$hooksAdded) {
        foreach (['localUrl', 'localHttpUrl', 'localName'] as $pageHook) {
            $pageHookFunction = 'hookPage' . ucfirst($pageHook);
            wire()->addHook("Page::{$pageHook}", null, function ($event) use ($pageHookFunction) {
                wire('modules')->LanguageSupportPageNames->{$pageHookFunction}($event);
            });
        }
    }
    $hooksAdded = true;

	/* add URLs */
});

I started working on the video element feature, but that's not as straightforward as I thought.

  • Like 2
Link to comment
Share on other sites

  • bedak changed the title to MarkupSitemap: Fatal Error after updating to 0.8.1 (PHP 8+)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...