Question regarding XML-Sitemap and Jobposting Markup

Hello guys,

one of my customers uses ModX as CMS.

Since we have not been able to resolve the following two problems by ourselfes yet, I am looking forward to your help as experienced ModX users:

  1. Jobposting Markup

We implemented google’s JobPosting Markup using the “Rich Text” field type but ModX keeps adding p-Tags in front of every line which leads to irritations with the functionality of the markup. Sounds like this is NOT the right way to implement a script - even though we properly opended and closed the script-Tag.

Can you tell me which is the proper way to implement a script on a subpage?

I have a few options, Rich Text seems to be the only one close to the what I want to accomplish though.

  1. XML-Sitemap

Secondly, the website of my customer contains a XML-Sitemap we would like to add several urls to but have not been able to figure out how to add links to it yet.

Navigating to Extras > Packages shows me a list of several packages including GoogleSiteMap which sounds to likely be responsible. The last update was 17.06.2024.

I do not see any possibility to add or remove urls from the sitemap within ModX though. I certainly can check “Published”, but there are several other urls that have this checked too and do NOT show in the XML-Sitemap.

In case there are better ways to implement one or two of the points mentioned (markup, sitemap, plugins seen as best practice) feel free to tell me which one I should be using.

Looking forward to your replys!

Best regards
Thomas

  1. I’m not clear on exactly where you’re doing this but it sounds like you’re using a Template Variable. If so, try using “Text Area” instead of “Rich Text” as rich text editors often add markup to content, just as you’re describing.
  2. MODX itself does not automatically generate sitemaps but there are some extras that do, like GoogleSiteMap. I haven’t used any of them myself but I would imagine the documentation would cover how to modify/include/exlude items.

I would probably use a chunk for this (or generate the script tag with the JSON data in a snippet).
You could also install the extra Ace and then if the flag “ Rich Text” is disabled for the resource, the “content” field shows a code editor.

If the extra “GoogleSiteMap” is used, you can specify what resources to include in the snippet call. Take a look at the documentation of this extra.

There exist also different extras to create the sitemap.
For example SEO Suite (that gives more control for individual resources) or “pdoSitemap” (from to pdoTools) extra.

Thank you for your replys!

@dev_willis

  1. I unfortunately can not select a Text Area.
  2. I see where you are going, the GoogleSiteMap is implemented completely plane though (without any exclusions etc.), so I would expect ModX to actually just list all available urls which it does not.

@halftrainedharry
Can you tell me where I can find a chunk in ModX? In case that is a certain field, I unfortunately can not select it.
I just installed Ace, but when I added a new “Rich Text” field, pasted my JSON in and pressed the code Icon (<>) a few times, ModX put the p-Tags in front of the lines yet again.

I certainly missunderstood one/both of you at some point so I would be really glad if you could give me further assistance.

Adding the sitemap via SEO Suite worked btw, thank you!

Thank you!

Chunks are located under the “Elements” tab.
They are used for parts of the HTML code, that then can be included (for example) into a template (or resource content) with the MODX tag [[$name_of_the_chunk]].


What exactly do you mean by “added a new … field”? Is this a Template Variable?
If so, why can’t you use “Textarea” as the “Input Type”?


It’s still not exactly clear where you try to input your script-tag for the job listings. Is this a Template Variable or the content of a resource or the template?

Thank you for your fast reply!

I see! Found the chunks and pasted my JSON for one of the jobs in them (in between the script-Tags.

If I past the “[[$Test]]” into the Rich Text field and pressed the code icon a few times I end up with the same result though. I only do that to verify modx does not mess up the code.

With “added a new … field” I mean adding a content type “Rich Text” to a ressource.

Using a chunk works for me too, if you can tell/explain me the lasting way to do it. Otherwise my customer is probably going to inform me the code is yet again visibile on the subpage within the next days.

I see, you are using the extra ContentBlocks for the content of your resource.

If I remember correctly, there should be other field types available (in addition to the ones shown in your screenshot) like “Chunk” and I believe “HTML-Content” (for code input). Or you could use a Repeater.

(Unfortunately I currently don’t have access to a site with ContentBlocks installed, as this is a paid extra.)
Maybe go to “Extras” → “ContentBlocks” (in the menu) and check if you can add more field types to this template/layout.

Thank you for your reply!

You are right, there is “ContentBlock” in the “Extras” menu (since I do not know alot about ModX itself - my job is the SEO part - I did not even know that is an extention or something like that).

The window showing now “just” shows all the fields that you can see in the previously attached screenshot.

If I click on “Feld hinzufügen” (add field) in this window, I see the following screen:

Is the “Eigenschaften” > “Template” section where I should be able to place the [[$Test]] OR the entire JavaScript snippet?

If writing back and forth here is too inconvenient there is also the way to set up a small Google Meet call you can charge if you want.

Are you sure there are no other field types listed under the menu “Extras” → “ContentBlocks”? According to the documentation there should be a Chunk Selector or a Code predefined input type.


If you create a custom input type, then the “Eigenschaften” → “Template” section is similar to a chunk. You can add HTML markup and use placeholders like [[+FieldName]] for the fields the user fills in on the page. Maybe take a look at types like “Ansprechpartner” or “Jobs” which seem to be custom types, if you want to create something similar (possibly using a Repeater).


If you want to use a chunk, it might also be possible to include it directly into the template that is used for this resource. Check on the resource, what template is used and then adapt the template under “Elements” → “Templates” (above the section where chunks are created).

You’re more than welcome to grab a free development license if you ever want to play with it :wink: All features, no time limit, just a limit on the domain. See this list for allowed domains

Typically, a fields’ template contains something like [[+value]], which allows the content you put in the resource to be passed through to the front-end.

Make sure that on the “Allgemein” tab you select the field type you want to use. Like @halftrainedharry says, either a Chunk or Code input type seems best for what you’re trying to do. With the Code type, you just enter your code in the resource, plus you get some syntax highlighting as a bonus to make editing easier.

What you can also try, is just disabling ContentBlocks on the resource. When editing the resource go to the Settings tab, and change “Use ContentBlocks” to “No”. Save, the page reloads, and now you’re bypassing ContentBlocks entirely for that specific page, removing the functionality where you have layouts and field types to add. For minimising the markup you want on the sitemap page, that’s definitely easier then setting up empty layouts and fields for the same purpose.

2 Likes

Yet again, thank you for your replys!

@markh
I tried to disable Content Blocks for an example ressource, when I go to that ressource within the Ressources tab and navigate to “Settings” I do not have an option to disable it for that ressource though. :confused: All I see is this:

@halftrainedharry
I indeed see more then the elements I created you a screenshot of. I see HTML Code for example. I can not select it when I am in the ressource though.

I just tried to create a new field in Content Blocks, gave it a type of Code and was able to insert it into the ressource, I was even able to select wheather I want HTML Code, JavaScript or PHP. But when I save the page, I receive a 500 server error (I am working on the staging environment).
And when I delete this peace and save again, also deleting the cache and rebuilding all urls, I still end up with the server error.

As this is no hobby but a client project, is there a way I have a 15 minute conversion with one of you in the next days to finish this quickly? We can of course write posts back and forth and I am not against that, I just honor your time and do not want to be a time waste to you! :slight_smile: