getResources adding in unexpected items / sub domain to a URL it generates

I have a issue for quite a long time with getResources in that sometimes it adds in an unexpected sub-domain into the URL it creates. I’ve asked about this before and never really figured out why. It is a problem, as while it doesn’t break the link - I have a SSL and the additional subdomain throws up a ‘Your connection isn’t private’ / Not Secure message in both Edge and Chrome.

Step to reproduce

Here is the call
[[getResources? &parents=2 &limit=3 &tpl=news-new-home &includeContent=1 &includeTVs=1 &processTVs=1 &tvFilters=categoryoptions==%People%]]

And the Template html

<div class="card p-3 col-12 col-md-6 col-lg-4">
                <div class="card-wrapper">
                    <div class="card-img">
<a href="[[~[[+id]]]]" title="[[+pagetitle]]"><img title="[[+pagetitle]]" alt="[[+description]]" src="../[[+tv.imagetv]]"></img></a>
                    <div class="card-box">
                        <h4 class="card-title pb-3 mbr-fonts-style display-7"><a href="[[~[[+id]]]]" title="[[+pagetitle]]">[[+pagetitle]]</a></h4>
                        <p class="mbr-text mbr-fonts-style display-7">
                           [[+introtext:limit=`500`]] <a href="[[~[[+id]]]]" title="[[+pagetitle]]">Read more...</a>

And this is one of the pages where the issue happens - it is towards the bottom of the page, where the getResources call finds the latest 3 blog posts in the category People and returns an image, some introtext, and the title and obviously the relevant URL link,

Observed behavior

This is where the problem lies, it should produce something like;

Published press portraits | DJC Design - instead it produces this

and in the past it has been and loads of other things

Any ideas please? Thanks, David


MODX Revolution 2.8.3-pl, Apache: 2.4.39, MySQL: 5.6.25

I don’t think this has anything to do with getResources. The URL is generated with a MODx Link tag ([[~[[+id]]]]), so you should see the same output if put a tag like [[~123]] directly in your template.

By default the Link tag should generate a relative URL, so I’m a bit confused why it outputs an absolute URL in your case.

  • Are those pages you link to in a different context?
  • Has this context a different value for site_url?

yes, generating a relative link would avoid this problem but not sure how that is done here

as for different context - not sure what you mean - they are pages within a container called ‘blog’ and use a different Template but that is it

and checked the site_url on both pages are they are the same -

thanks for looking

also to add - it doesn’t seem to happen all the time, which is very strange - I’ve just restarted a browser and loaded the same page as above and the error has gone and it’s now showing the correct URL

as i said, it has been one of those problems that has been there for years and i’ve never figured it out

You can add a scheme property to your Link tag [[~[[*id]]? &scheme=`-1`]]. (But as -1 is the default this shouldn’t make any difference.)

Have you tried calling the Link tag uncached?
[[!~[[*id]]]] (With a ! at the beginning)

Mutliple contexts are usually used for multi-language websites or when you have different domains you want to manage with one MODx installation.

You can manage them in the manager via the ‘cog wheel’ icon → Contexts (web & mgr by default). You get different resource-trees on the left side of your manager.

Screenshot 2021-11-15 at 15-30-35 Context ua MODX Revolution

thanks for helping out - I’ve added into the Call the uncached link as suggested and I will check it over time

as for Contexts - it did have Provisioner - which i think dates back to years ago when i migrated content from an Evolution version of the site to the current Rev - I’ve uninstalled and removed - so fingers crossed

Turns out there is a system setting link_tag_scheme that defines the default scheme (and you probably changed that to https).
So [[~[[*id]]? &scheme=`-1`]] should make a difference.

But that still doesn’t explain the different subdomains.

Is there a reason why anyone would call your site with or
Maybe you could also try to add a rewrite rule to your .htaccess file based on %{HTTP_HOST}?

ummm, still getting different subdomains every now and again on my internal links

the latest have been pointing to

could it be a DNS issue - something is replacing the www with random DNS settings?

“pop”, “imap” and “mx1” all seem to be email related. Is this server/domain used to send email or access email accounts? Maybe these are just calls from spam bots trying to find an unprotected email server or something.

It’s somewhat unusual that your server seems to accept every arbitrary subdomain. Maybe you can change that somewhere in your server configuration or add a rule to the .htaccess file to disallow subdomains.