Jump to content

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@bedak Thanks for your suggestion – happy to implement, but am stuck for time… 🙈 Will open an issue on the repo in the meantime. 😊

Edit: If you feel you can add this in from your side, feel free to submit a merge request to https://gitlab.com/rockettpw/seo/markup-sitemap

Edited by Mike Rockett
  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
3 minutes ago, Mike Rockett said:

The module has been published to Packagist, under rockett/sitemap. 🙂

Awesome, thanks Mike! 🙂

 

Share this post


Link to post
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\":\"\"}}"}

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MateThemes
      Hello everyone!
      I have a markup and image field question:
      I have a markup in which a gallery preview should be displayed on home page. This gallery have a special markup, 3 of 4 images have special image ratio.

      The gallery looks like this. 
      The html markup is like this:
      <div class="uk-section-muted" uk-scrollspy="target: [uk-scrollspy-class]; cls: uk-animation-slide-top-small; delay: 200;"> <div data-src="./assets/images/arrahof/home-restaurant-bg.svg" class="uk-background-norepeat uk-background-contain uk-background-top-center uk-section uk-section-large" uk-img> <div class="uk-container uk-container-small"> <div class="uk-margin-large" uk-grid> <div class="uk-width-1-1@m"> <h2 class="uk-text-center" uk-scrollspy-class>Das Angebot im ArraHof</h2> </div> </div> <div class="uk-grid-small uk-grid-margin-small" uk-grid> <div class="uk-width-expand@s"> <div class="uk-margin-remove-vertical uk-text-center" uk-scrollspy-class> <a class="el-container uk-inline-clip uk-transition-toggle uk-link-reset" href="#"> <img class="el-image" data-src="https://via.placeholder.com/610x604" data-sizes="(min-width: 610px) 610px" data-width="610" data-height="604" alt="Placeholder Image" uk-img> <div class="uk-overlay-default uk-transition-fade uk-position-cover"></div> <div class="uk-position-center uk-position-small"> <div class="uk-overlay uk-padding-large uk-transition-fade uk-margin-remove-first-child"> <h3 class="el-title uk-h4 uk-heading-divider uk-transition-slide-top-small uk-margin-top uk-margin-remove-bottom">Lorem Ipsum</h3> <div class="el-content uk-panel uk-transition-slide-bottom-small uk-margin-top">Comfort Food</div> </div> </div> </a> </div> </div> <div class="uk-width-expand@s"> <div class="uk-margin-remove-vertical uk-text-center" uk-scrollspy-class> <a class="el-container uk-inline-clip uk-transition-toggle uk-link-reset" href="#"> <img class="el-image" data-src="https://via.placeholder.com/610x604" data-sizes="(min-width: 610px) 610px" data-width="610" data-height="604" alt="Placeholder Image" uk-img> <div class="uk-overlay-default uk-transition-fade uk-position-cover"></div> <div class="uk-position-center uk-position-small"> <div class="uk-overlay uk-transition-fade uk-margin-remove-first-child"> <h3 class="el-title uk-h4 uk-heading-divider uk-transition-slide-top-small uk-margin-top uk-margin-remove-bottom">The Williams family</h3> <div class="el-content uk-panel uk-transition-slide-bottom-small uk-margin-top">Comfort Food</div> </div> </div> </a> </div> </div> </div> <div class="uk-grid-small uk-grid-margin-small" uk-grid uk-height-match="target: .uk-card; row: false"> <div class="uk-width-2-3@s"> <div class="uk-margin-remove-vertical uk-text-center" uk-scrollspy-class> <a class="el-container uk-inline-clip uk-transition-toggle uk-link-reset" href="#"> <img class="el-image" data-src="https://via.placeholder.com/610x400" data-width="610" data-height="400" alt="Placeholder Image" uk-img> <div class="uk-overlay-default uk-transition-fade uk-position-cover"></div> <div class="uk-position-center uk-position-small"> <div class="uk-overlay uk-transition-fade uk-margin-remove-first-child"> <h3 class="el-title uk-h4 uk-heading-divider uk-transition-slide-top-small uk-margin-top uk-margin-remove-bottom">The Williams family</h3> <div class="el-content uk-panel uk-transition-slide-bottom-small uk-margin-top">Comfort Food</div> </div> </div> </div> </a> </div> <div class="uk-width-expand@s"> <div class="uk-margin-remove-vertical uk-text-center" uk-scrollspy-class> <a class="el-container uk-inline-clip uk-transition-toggle uk-link-reset" href="#"> <img class="el-image" data-src="https://via.placeholder.com/610x820" data-sizes="(min-width: 610px) 610px" data-width="610" data-height="820" alt="Placeholder Image" uk-img> <div class="uk-overlay-default uk-transition-fade uk-position-cover"></div> <div class="uk-position-center uk-position-small"> <div class="uk-overlay uk-transition-fade uk-margin-remove-first-child"> <h3 class="el-title uk-h4 uk-heading-divider uk-transition-slide-top-small uk-margin-top uk-margin-remove-bottom">The Williams family</h3> <div class="el-content uk-panel uk-transition-slide-bottom-small uk-margin-top">Comfort Food</div> </div> </div> </div> </a> </div> </div> </div> <div class="uk-margin-large" uk-grid> <div class="uk-width-1-1@m"> <div class="uk-text-lead uk-width-xxlarge uk-margin-auto uk-text-center" uk-scrollspy-class>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur.</div> <div class="uk-margin-medium uk-text-center" uk-scrollspy-class> <a class="el-content uk-button uk-button-default uk-button-large" href="#">Unterkunft</a> </div> </div> </div> </div> </div> How can I achieve when I have an image field to add the custom markup within the image field? I have no clue to get this done.
      Thank you!
    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.


    • By stanoliver
      My aim is to output a very basic xml document which should be styled with a few css-styles.
      <?xml version = "1.0"?> <contact-info> <name>Donal Duck</name> <company>Superducks</company> <phone>(011) 123-4567</phone> </contact-info> How do I implement it with processwire?
    • By franciccio-ITALIANO
      Hi, we can choose the "headline" and "title" and "summery" in panel page of processwire, but we can't write the "metadecriptions" and "tags".
       I can write mdescropt and tags in templates, but I've same templates for many articles... so, how I can change mdescription and tags?

      Thanks...
    • By Leftfield
      Hi All 🙂

      How to append canonical URL to head from certain templates?

      Thanks!!!
×
×
  • Create New...